1. findfont

Obtain font dictionary by name.

1.1. Syntax

key findfont font

1.2. Stack Effects

Before:

key

After:

font

1.3. Description

findfont obtains a font dictionary identified by the specified key and pushes it on the operand stack. The key may be a key previously passed to definefont, in which case the font dictionary associated with key (in the font directory) is returned.

If key is not registered as a font in VM, findfont takes an action that varies according to the environment in which the PostScript interpreter is operating. In some environments, findfont may attempt to read a font definition from an external source, such as a file. In other environments, findfont substitutes a default font or executes the error invalidfont.

findfont is a special case of findresource applied to the Font category.

findfont, like findresource, normally looks first for fonts defined in local VM, then for fonts defined in global VM. However, if the current VM allocation mode is global, findfont considers only fonts defined in global VM. If findfont needs to load a font into VM, it may use either local or global VM, depending on the font. Generally, Type 1 fonts are loaded into global VM; fonts of other types are loaded into local VM.

findfont is not an operator, but rather a built-in procedure. It may be redefined by a PostScript language program that requires different strategies for finding fonts.

1.4. Parameters

key (name or string) : The name of the font to find (e.g., /Helvetica, /Times-Roman)

1.5. Returns

font (dictionary) : The font dictionary associated with the specified key

1.6. Examples

1.6.1. Basic Font Loading

/Helvetica findfont
% Returns the Helvetica font dictionary

1.6.2. Loading and Using a Font

/Times-Roman findfont    % Get Times-Roman font
12 scalefont             % Scale to 12 points
setfont                  % Set as current font

1.6.3. Font with Fallback

{
  /MyCustomFont findfont
} stopped {
  pop  % Remove error
  /Helvetica findfont  % Use fallback font
} if

1.7. Errors

invalidfont : If the font name is not valid or the font dictionary is malformed

stackunderflow : If the operand stack is empty

typecheck : If key is not a name or string

1.8. Font Discovery

The font discovery mechanism varies by implementation:

  1. Local VM fonts - Defined by definefont in local VM

  2. Global VM fonts - Defined by definefont in global VM

  3. External fonts - Loaded from font files or other external sources

  4. Substitution fonts - Default fonts substituted when requested font not found

1.9. VM Allocation

When loading fonts from external sources:

  • Type 1 fonts are typically loaded into global VM

  • Other font types are typically loaded into local VM

  • The current VM allocation mode affects which fonts are visible

1.10. See Also


Back to top

Copyright © 2025 Ribose. PostScript is a trademark of Adobe. Distributed under the MIT License.