1. makefont
Transform font by arbitrary matrix.
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.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.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 |
|
Horizontal scaling by sx |
|
Vertical scaling by sy |
|
Slant/oblique by angle θ |
|
Rotation by angle θ |
|
Horizontal flip |
|
Vertical flip |
|
1.10. See Also
-
findfont- Obtain font dictionary by name -
scalefont- Scale font by uniform factor (simpler) -
setfont- Establish current font -
currentfont- Get current font dictionary