home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PRINTING / DVIPS54.ZIP / DVIPS / TEXPS.LPR < prev    next >
Text File  |  1990-11-25  |  4KB  |  98 lines

  1. % PostScript prolog for using resident fonts.
  2. % No change is made to the encoding scheme, since `virtual fonts' do that
  3. % better. All we do is change the widths so that PostScript positioning
  4. % matches the assumptions of dvips.
  5.  
  6. % The calling sequence defining font foo to be resident font Bar is
  7. %           /foo [wd0 wd1 ... wd255] /Bar mag atsize rf
  8. % where each character width wdi is in pixels,
  9. % mag is the magnification per thousand,
  10. % and atsize is the desired font size in TeX scaled points (sp).
  11.  
  12. %
  13. TeXDict begin
  14. %
  15. /rf {
  16. 655360 div mul Resolution mul 7227 div /PixPerEm X % compute pixels/em
  17. % We copy everything but the FID entry of the resident font
  18. % (just as in section 5.7 of the Red Book)
  19. findfont
  20. dup length 1 add dict /nn X
  21.    {1 index /FID ne
  22.       {nn 3 1 roll put}
  23.       {pop pop}
  24.       ifelse
  25.    } forall
  26. % Now the top entry on the stack is the array of pixel widths.
  27. % We convert them to PostScript's milli-em units, and put them
  28. % in a Metrics dictionary.
  29.   256 dict begin
  30.      nn /Encoding get
  31.      0 1 255 {
  32.        2 copy get
  33.        3 index 2 index get 
  34.        1000 mul PixPerEm div N pop
  35.      } for
  36.   pop pop
  37.   nn /Metrics currentdict put end
  38. % Finally we associate the new font with a name like ZZfoo@,
  39. % using conventions identical to those of downloaded bitmap fonts.
  40.    /fontname X
  41. %  dmystr 2 fontname cvx (@@@@) cvs putinterval  % put name in template
  42.    /nn dup nn definefont
  43.    [PixPerEm 0 0 PixPerEm neg 0 0] makefont N
  44.    fontname { /foo setfont }       %  dummy macro to be filled in
  45.       2 array copy cvx N         %  have to allocate a new one
  46.    fontname load                   %  now we change it
  47. %     0 dmystr 6 string copy       %  get a copy of the font name
  48.       0 nn put                %  get the actual dictionary
  49. %     cvn cvx put                  %  and stick it in the dummy macro
  50. } B
  51.  
  52. %
  53. %   Now here's some oblique hackery... an example of making
  54. %   variants of a resident font look like it is resident.
  55. %   Say, e.g., /Times-Slanted /Times-Roman .167 SlantFont
  56. %   to make /Times-Slanted a font with slant of 1/6;
  57. %   or /Times-Extended /Times-Roman 1.05 ExtendFont
  58. %   to make a font that's 5% wider.
  59. %   Optionally replace the `slant' by `angle ObliqueSlant';
  60. %   note that the ObliqueSlant of Times-Italic is -15.5 (negative).
  61. %
  62. /ObliqueSlant {   % angle ObliqueSlant slant
  63.     dup sin S cos div neg
  64.     } B
  65.  
  66. /SlantFont {      % fontname basefontname slant SlantFont pseudoresfontname
  67.     /foo X
  68.     [1 0 foo 1 0 0] TransFont
  69.     } B
  70.  
  71. /ExtendFont {     % widtharray fontname basefontname factor ExtendFont
  72.                   %     widtharray' pseudoresfontname
  73.     /foo X
  74.     3 2 roll [ S {foo div} forall ] % divide each width entry by the factor
  75.     3 1 roll [foo 0 0 1 0 0] TransFont
  76.     } B
  77.  
  78. % Note: After Times-Slanted is declared once as a SlantFont, you can
  79. % use it again without redeclaring its relation to Times-Roman.
  80. % But this doesn't work with Times-Extended, because you have to
  81. % recompute the widths for each incarnation of Times-Extended.
  82. % In fact, strictly speaking, it doesn't work even with Times-Slanted,
  83. % because the widths are rounded differently at different sizes.
  84. % Therefore dvips repeats the special instructions each time.
  85.  
  86. /TransFont {      % fontname basefontname matrix TransFont pseudoresfontname
  87.     S findfont S makefont
  88.     dup length dict /nn X
  89.        {1 index /FID ne
  90.           {nn 3 1 roll put}
  91.           {pop pop}
  92.        ifelse
  93.        } forall
  94.     dup nn definefont pop
  95.     } B
  96. %
  97. end
  98.