1. scalefont

Scale font by uniform factor.

1.1. Syntax

font scale scalefont font'

1.2. Stack Effects

Before:

font scale

After:

font'

1.3. Description

scalefont applies the scale factor scale to font, producing a new font' whose characters are scaled by scale (in both x and y) when they are shown. scalefont first creates a copy of font, then replaces the new font’s FontMatrix entry with the result of scaling the existing FontMatrix by scale.

It inserts two additional entries, OrigFont and ScaleMatrix, whose purpose is internal to the implementation. Finally, it returns the result as font'.

Showing characters from the transformed font produces the same results as showing from the original font after having scaled user space by the factor scale in both x and y by means of the scale operator.

scalefont is essentially a convenience operator that enables the desired scale factor to be encapsulated in the font description. Another operator, makefont, performs more general transformations than simple scaling.

The interpreter keeps track of font dictionaries recently created by scalefont. Calling scalefont multiple times with the same font and scale will usually return the same font' rather than create a new one each time. However, it is usually more efficient for a PostScript language program to apply scalefont only once for each font that it needs and to keep track of the resulting font dictionaries on its own.

1.4. VM Allocation

The makefont, scalefont, and selectfont operators produce a font dictionary derived from an original font dictionary, but with the FontMatrix entry altered. The derived font dictionary is allocated in local or global VM according to whether the original font dictionary is in local or global VM. This is independent of the current VM allocation mode.

1.5. Parameters

font (dictionary) : The original font dictionary to scale

scale (number) : The uniform scale factor to apply in both x and y dimensions

1.6. Returns

font' (dictionary) : A new font dictionary with scaled character metrics

1.7. Examples

1.7.1. Basic Font Scaling

/Helvetica findfont    % Get Helvetica font
12 scalefont           % Scale to 12 points
setfont                % Set as current font

1.7.2. Creating Multiple Sizes

/Helvetica findfont
dup 10 scalefont /H10 exch def   % 10-point Helvetica
dup 12 scalefont /H12 exch def   % 12-point Helvetica
    18 scalefont /H18 exch def   % 18-point Helvetica

1.7.3. Scaling for Different Units

% The standard font has 1-unit line height
/Helvetica findfont
12 scalefont setfont

% Creates a 12-unit high font (12-point in default user space)
% Characters have same proportions as original font

1.8. Errors

invalidfont : If font is not a valid font dictionary

stackunderflow : If fewer than two operands are on the stack

typecheck : If font is not a dictionary or scale is not a number

undefined : If required font dictionary entries are missing

1.9. Font Scaling Behavior

The scale factor affects:

  • Character widths in both x and y

  • Character heights

  • All font metrics proportionally

The scale transformation is applied by modifying the FontMatrix:

FontMatrix' = [scale 0 0 scale 0 0] × FontMatrix

1.10. See Also

  • findfont - Obtain font dictionary by name

  • makefont - Transform font by matrix (for non-uniform scaling)

  • setfont - Establish current font

  • currentfont - Get current font dictionary


Back to top

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