I hope this is not too off topic here, since I cannot think of a place with more experts where I could ask. The background is, that I want to improve my ASCII-art algorithm which works fine (about 70k letters here) but I have some other ideas I want to implement:
Beside some details of the algorithm itself, I want to implement the following:
I want to place say 500x500 letters in a way that the line-space is as big as the interletter space and that the font-size is calculated automatically so that this rectangle fits onto some (say A4) paper size. Here is a minimal postscript example I hacked up for testing
%!PS-Adobe-2.0 %%Creator: email@example.com %%EndComments /Courier findfont 7.7 scalefont setfont 72 500 translate 0 0 moveto (abcdefhikl) show 0 -5 moveto (mnorstuvwx) show 0 -10 moveto (zABCDEFGHI) show 0 -15 moveto (JKLMNOPRS!) show 0 -20 moveto (TUVWXYZ.=-) show 0 -25 moveto showpage %%Pages: 1
Note that I just guessed the font-scaling and the
Question: If I only now how many letters nx*ny I have, is it possible to calculate the font-scaling the the
moveto size so that the rectangle fits on the paper?
Font brightness calculation
For a really good output, I need to calculate the brightness of the letters as precisely as possible. In the image of the ps-file above, you see that all letters are surrounded by a small white border. This border depends in x-direction on the inter-letter distance and in y-direction on the font-scale/
Question: Is it possible to create a high-resolution image (png, tiff, ..) of every letter? Note, for a correct calculation the white border in the images is required to be the same size as if the letter would be surrounded by other letters.
I decided not to take letters like "Qyg" which have a sub-length because they are very rare and make the lines be more appart. This makes the calculation of the correct line-space maybe impossible.
I'm always open for other suggestions. I chose the post-script output because I can transform the ascii-text really easy into the
(...) show; ... moveto form. And, I have control over the letter scaling and distances. Maybe there is a better/easier way.