I newer saw this but I did bitmap to ASCII art converter in the past which is similar. so from my point of view I see it like this:
take gray-scale image and segmentate it (by rectangle areas with fixed aspect ratio)
Aspect ratio is given by input text phrase and Font used. This will give you list of rectangles with similar colors so compute average color for them. Also a good idea is to limit min and max size of segments
- too small rectangles are unreadable
- too big rectangles are ugly (see the biggest GENIUS)
replace rectangle segments by text
Font size is limited by filled area (rectangle size) so text will fit into it. Average color of text should be the same as average color of rectangle segment
text_color=rectangle_avg_color*(ink_pixels+paper_pixels)/ink_pixels
ink_pixels
and paper_pixels
are the count of pixels in rendered text phrase. If you want to implement colored images then just compute R,G,B values separately and blend it together or segmentate by colors and intensities at once
See Image to ASCII Art conversion it may help you got some new ideas ...