1. makefont

Transform font by arbitrary matrix.

1.1. Syntax

font matrix makefont → font'

1.2. Stack Effects

Before:

font matrix

After:

font'

1.3. Description

makefont applies matrix to font, producing a new font' whose characters are transformed by matrix when they are shown. makefont first creates a copy of font. Then it replaces the new font’s FontMatrix entry with the result of concatenating the existing FontMatrix with matrix. It inserts two additional entries, OrigFont and ScaleMatrix, whose purpose is internal to the implementation. Finally, it returns the result as font'.

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.

Normally, makefont copies only the font dictionary. Subsidiary objects, such as the CharStrings and FontInfo dictionaries, are shared with the original font. However, if font is a composite font, makefont also copies the font dictionaries of any descendant composite fonts. It does not copy descendant base fonts.

Showing characters from the transformed font produces the same results as showing from the original font after having transformed user space by the same matrix. makefont is essentially a convenience operator that permits the desired transformation to be encapsulated in the font description.

The most common transformation is to scale a font by a uniform factor in both x and y. scalefont is a special case of the more general makefont and should be used for such uniform scaling.

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

1.4. Parameters

font (dictionary) : The original font dictionary to transform

matrix (array) : A 6-element transformation matrix [a b c d tx ty]

1.5. Returns

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

1.6. Examples

1.6.1. Non-Uniform Scaling (Condensed Font)

/Helvetica findfont
[10 0 0 12 0 0] makefont setfont

% Creates a 12-unit high font (12-point in default user space)
% with characters condensed in x dimension by ratio of 10/12

1.6.2. Oblique (Slanted) Font

/Helvetica findfont
[12 0 3 12 0 0] makefont setfont

% Creates an oblique/italic effect
% Characters are slanted to the right

1.6.3. Scaled and Rotated Font

/Helvetica findfont
matrix
12 12 scale      % Scale to 12 points
45 rotate        % Rotate 45 degrees
makefont setfont

% Characters are scaled and rotated

1.6.4. Mirror Font (Horizontal Flip)

/Helvetica findfont
[-12 0 0 12 0 0] makefont setfont

% Negative x scale creates mirror image

1.7. Errors

invalidfont : If font is not a valid font dictionary

rangecheck : If matrix is not exactly 6 elements or values exceed limits

stackunderflow : If fewer than two operands are on the stack

typecheck : If font is not a dictionary or matrix is not an array

VMerror : Insufficient VM to create the new font dictionary

1.8. Font Matrix Transformation

The transformation is applied by modifying the FontMatrix:

FontMatrix' = matrix × FontMatrix

The matrix format is:

[a  b  c  d  tx  ty]

This transforms coordinates as:

x' = a×x + c×y + tx
y' = b×x + d×y + ty

1.9. Common Transformation Patterns

Effect Matrix

Uniform scaling by s

[s 0 0 s 0 0]

Horizontal scaling by sx

[sx 0 0 1 0 0]

Vertical scaling by sy

[1 0 0 sy 0 0]

Slant/oblique by angle θ

[1 0 tan(θ) 1 0 0]

Rotation by angle θ

[cos(θ) sin(θ) -sin(θ) cos(θ) 0 0]

Horizontal flip

[-1 0 0 1 0 0]

Vertical flip

[1 0 0 -1 0 0]

1.10. See Also


Back to top

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