%!PS % POSTSCRIPT TRUE INTEGRAL GRAYSCALE ANTIALIASED FONT GENERATOR V1.8 % ================================================================= % Copyright c 2001 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.8 % Attractively showing smaller size fonts on screens, during image retouches, or % on ebooks requires special techniques. One of these is anti-aliasing which % we looked at in http://www.tinaja.com/glib/muse141.pdf % Traditional anti-aliasing (as used in Acrobat and Ghostscript and elsewhere) % is simply a Gaussian low pass spatial filter. While useful to eliminate % jaggies, and while it works quickly with any input, no new information is % added to the basic font content. % A powerful alternative is true integral grayscale antialiasing. Since this % font and size specific technique can provide up to 32 TIMES the information % content in a given number of pixels, the presentation of small fonts can be % dramatically improved. % A grayscale antialiased font character is really a gray glyph of the desired % number of pixels. Such as this 5 pixel by 7 pixel example... % GGGGG % GGGGG % GGGGG % GGGGG % GGGGG % GGGGG % GGGGG % Each G is a gray value in suitable units. Here is an "S" 5x7 7-point example % with 0.000 = black and 0.999 = white... % [0.609 0.014 0.000 0.054 0.749] % [0.117 0.564 0.871 0.362 0.247] % [0.124 0.317 0.747 0.957 0.957] % [0.697 0.132 0.000 0.054 0.569] % [0.849 0.969 0.852 0.412 0.022] % [0.062 0.509 0.871 0.584 0.049] % [0.614 0.029 0.000 0.024 0.584] % The rule is to take a "perfect" font and then decide which percentage of each % pixel is to be black. That percentage then becomes a gray value to be displayed. % Unlike conventional Gaussian anti-aliasing, there is no smearing. % Because of the extra information, viewibility is very dramatically improved at % smaller font sizes on lower resolution screens or ebooks. % A demo appears at http://www.tinaja.com/psutils/pdf2bmp.bmp with its corresponding % sourcecode at http://www.tinaja.com/psutils/pdf2bmp.psl % The utilities presented here let you generate true integral grayscale fonts. % They are "semi-automatic" in that you first have to carefully position your % font in pixel space (allowing for maximizing, symmetry, optical clipping, etc...) % and later have to transfer each individual glyph into a seperate font file. % To use, view in editor or word processor, guess at font character positioning, % then send to Distiller or GhostScript. View PDF. Adjust for the best positioning, % redistill, and then copy the generated true integral gray antialiased font % character from your log file to an appropriate font definition file. % The present file is currently fixed at 5 x 7 pixels nominal (less if J, more if W) % but is easily adapted to all needed sizes. There are 400 samples per pixel. % The desired font MUST be findable by Distiller. Otherwise rectangular bounding % boxes for MM fonts or Courier substitution may inadvertently be made. % My Gonzo utilities are presently needed to for these concepts. To use, % obtain then uncomment ONE of the following two lines... (C:/Users/don/Desktop/gonzo/gonzo.psl) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo gonzo begin % open gonzo utilities ps.util.1 begin nuisance begin % Utilities available via http://www.tinaja.com/post01.asp %%%%%%%% INTEGRAL GRAYSCALE ANTIALIASING ROUTINES %%%%%%%%%%%% 50 50 9 setgrid % establish unit grid /xwide 84.8 store % width of character carefully fitted to grid /yhigh 97.7 store % height of character carefully fitted to grid /xoffset -4.4 store % usually adjusted for flush left /yoffset 1.1 store % usually zero; adjust for optical C,O, etc. /sixwide false store % extends grid one wider for W, M /font1 /Helvetica-Bold [xwide 0 0 yhigh 0 0 ] gonzofont % definte the font font1 xwide == yhigh == xoffset == % print parameters to pass as comments to output xoffset yoffset moveto (5) false charpath % put the character on the grid mark 6 -1 0 {/ccol exch store % for seven pixel columns mark 0 1 4 sixwide {1 add} if {/rrow exch store % for five (nominal) pixel rows 0 % zero a counter 0.25 .5 9.76 {/iii exch store % take 400 samples per pixels 0.25 .5 9.76 {/jjj exch store rrow 10 mul iii add % position microsample ccol 10 mul jjj add infill not % test for black/white {1 add} if % add one to counter if white } for } for 400 div % scale to unity 999.9 mul floor 1000 div % round to 0.000 to 0.999 } for ] } for ] /garray exch store % define glyph array garray == % output glyph array to log file 0.6 0.6 0.6 setrgbcolor fill % optionally show character %%%%%%%%%%%%%%% CONVENIENCE VISUAL SUPPORT OVERLAY %%%%%%%%%%%%%% 50 sixwide {10 add} if 70 showgrid % show entire pixel grid 0.5 0.5 0 setrgbcolor 0.2 setlinewidth % set outline size and color [{0 0 mt 70 u} 10 6 sixwide {1 add } if ] xrpt % outline pixels [{0 0 mt 50 sixwide {10 add} if r} 10 8 ] yrpt showpage % end of file