Search code examples
postscript

Postscript: How can I alias or substitute one font for another?


I want to check if the font exists and if it doesn't then substitute it for another and to make it work for every instance of the font in the document I can use: /font_a /Font resourcestatus dup { 3 1 roll pop pop } if {/font_a} {/font_b} ifelse findfont but I need to use it each time I use font_a. how to define it globally?

ps.sry for the broken english


Solution

  • Instead of using findfont/scalefont/selectfont throughout your document, define the fonts you'll use at the beginning of the file:

      /heading-font  /Helvetica-Bold findfont 14 scalefont def
      /body-font     /Times-Roman    findfont 11 scalefont def
      ...
      heading-font setfont (Trees) show
      body-font setfont  (A tree is a tall living structure made of wood.) show
      heading-font setfont (Lakes) show
      body-font setfont (A lake is a storage medium for water.) show
      ...
    

    You will still have to search through the font resources to see if the typefaces you want are available, but you will only have to do it once per typeface.