The callothersubr charstring command calls a PostScript procedure from the
Private dictionary’s OtherSubrs array. A Type 1 font uses it for four jobs:
flex and hint replacement (entries 0 to 3, in the Type 1 book), counter control (12 and 13)
and multiple master blending (14 to 18), the last two from Adobe’s Technical Note #5015.
The charstrings page lists the commands
themselves; this page says what these calls do and how a reader carries them out
without running PostScript.
Calling an OtherSubrs procedure
arg1 … argn n othersubr# callothersubr
The command takes the OtherSubrs entry number and the number of arguments n
from the top of the charstring stack, removes the n arguments under them and
hands them to the PostScript procedure. Whatever the procedure leaves on the PostScript
stack comes back to the charstring stack one value at a time with pop. The
stack of a charstring holds at most 24 numbers, which counts the two extra arguments.
Flex (OtherSubrs 0, 1 and 2)
Flex lets two curves that form a shallow hump or dent be drawn as a straight line at small sizes. If a font uses flex or hint replacement, its first four Subrs must be:
| Subr | Charstring | Job |
|---|---|---|
| 0 | 3 0 callothersubr pop pop setcurrentpoint return | Ends the flex: three arguments (the flex height and the end point), then the end point is set as the current point. |
| 1 | 0 1 callothersubr return | Starts a flex: the rmoveto commands that follow collect points instead of moving the pen. |
| 2 | 0 2 callothersubr return | Records the current point after each of the seven rmoveto commands. |
| 3 | return | Does nothing: it is the target of hint replacement. |
The charstring for a flex (Type 1 book, section 8.3) is: a call of Subr 1, then seven
pairs of an rmoveto and a call of Subr 2, then the flex height control
parameter and the final point in absolute character coordinates and a call of Subr 0:
1 callsubr
50 0 rmoveto 2 callsubr the reference point, relative to the starting point
-35 0 rmoveto 2 callsubr the first curve's first control point, relative to the reference point
10 10 rmoveto 2 callsubr
25 0 rmoveto 2 callsubr the joining point
25 0 rmoveto 2 callsubr
10 -10 rmoveto 2 callsubr
15 0 rmoveto 2 callsubr the end point
50 200 -10 0 callsubr height control 50, end point (200, -10)
The book’s example is two curves from (100, −10) through (150, 0) to (200, −10): the
seven points are the reference point and the three points of each curve, and the curves
are 115 -10 125 0 150 0 curveto and 175 0 185 -10 200 -10 curveto.
The reference point has the joining point’s x (horizontal flex) and the starting point’s y.
The first number of the final call is the height, in hundredths of a device pixel, at
which the curves are drawn as curves rather than a line (50 for cupped serifs and shapes
that meet overshoot zones). BlueShift, which is 7 by default, must be larger
than the largest flex height in the font (section 8.3), so a font with a flex taller than 6 sets
BlueShift to the height plus 1. A pair of curves can be a flex only when it is exactly two Bézier
segments, the outer end points are at one x or one y, the joining point and its control points are at the
extreme of the pair, and the height (outer end point to joining point) is 20 units or less. The viewer
reports flexes that break these as notes (see the rules).
Hint replacement (OtherSubrs 3)
A glyph whose stem hints change part-way (the E’s three bars against its stem, say) calls
a Subr that holds the new hstem and vstem commands:
subr# 1 3 callothersubr pop callsubr
OtherSubrs 3 takes the Subr number, a rasteriser that supports replacement may use it,
and pop returns the number (or 3, the empty Subr, if the rasteriser does not
do replacement) for callsubr to run. The new hints end with
return.
Counter control (OtherSubrs 12 and 13)
Counter control (Technical Note #5015, section 2) is for fonts with complex glyphs, mostly
East Asian. It tells the rasteriser which stems bound the counters (the white spaces) of a
glyph and in what groups, so that equal counters stay equal at small sizes. The Private
dictionary says the font uses it with /LanguageGroup 1 def and
/RndStemUp false def. A font without complex glyphs should avoid what makes
a two-pass rasteriser spend an extra pass on counter control: calls of entries 12 or 13, a
RndStemUp entry (any value) and a first BlueValues zone whose top edge is negative.
A1 A2 … An n 12 callothersubr more data follows
#H HG1 … HGn #V VG1 … VGn m 13 callothersubr the last call
- Each call carries at most 22 arguments (n from 0 to 22). A call of entry 12 means more data follows; the data is passed in groups of 22 until the rest fits, and the sequence ends with exactly one call of entry 13.
- The data is #H, the number of horizontal stem groups (0 if none), then the data for each group from the most important to the least, then #V and the vertical groups the same way; m is the number of arguments of the call.
- The calls must come immediately after
hsbworsbw, and only once in a glyph. Other hints and hint replacement are done as usual. - A rasteriser that does not know counter control runs the PostScript of entries 12 and 13, which only discards the arguments, so nothing piles up on the stack.
How a group is encoded
A group (TN 5015, section 2.4) is a list of coordinates for the counters between stems of one direction, adjusted relative to each other, “in ascending order (in character space) as pairs of numbers”. Each pair is the value of the left (or bottom) edge of a stem and the width of the stem, where the edge is written as the distance from the previous stem’s far edge (“the distance from zero (for the horizontal direction, the distance from the left sidebearing point) for the first entry”). The number of stems in a group is not given, so the sequence ends by making the distance to the final stem extend to the far edge of that stem and making the final width negative: “if the last pair of numbers would ordinarily be ‘…100 20…’, it must be encoded as ‘…120 –20…’”. Not every stem needs to be in a group. The order of the groups in the data is their priority: it decides the order in which they are allocated white space pixels, so the first group’s counters are the last to collapse at small sizes.
TN 5015 works an example, the glyph of its Figure 1. Its hstems are -44 58 155 25 445 25 703 25 273 25 430 25
582 25 735 25 (each y dy hstem) and its vstems 86 60 281 60 430 60 670 60 790 60, and
the groups are two of hstems and one of vstems:
2 155 25 265 25 258 -25 273 25 132 25 127 25 153 -25 1 86 60 135 60 89 60 360 -60
#H group 1 (3 stems) group 2 (4 stems) #V the vstem group (4 stems)
Group 1 is read as stems at 155 to 180, then 180 + 265 = 445 to 470, then the last pair puts the far edge at
470 + 258 = 728 and the width −25 makes it the stem 703 to 728. The whole list is 24 numbers, more than the 22 one call may carry, so it is split:
the end of the list goes in the call to entry 12 and the start in the call to 13, because the arguments are popped in
reverse: 25 265 25 258 -25 273 25 132 25 127 25 153 -25 1 86 60 135 60 89 60 360 -60 22 12
callothersubr then 2 155 2 13 callothersubr.
Multiple master fonts
A multiple master font (Technical Note #5015, section 3) holds several master designs of a typeface at the corners of a design space, and any point of the space is an instance. Its program keeps the masters’ outlines together: each number that differs between masters is stored once, as the first master’s value followed by the differences to the others, and a procedure blends them with weights.
- Design space. One to four axes (weight, width, optical size, style). Design coordinates are integers the designer chooses, usually 1 to 999 (Viva, 1 to 2000); blend coordinates are 0 to 1 and are what the rasteriser uses. A font has 2 to 16 masters, with 2n + x = 16 for n axes and x intermediate designs (the note says intermediate designs are not supported by ATM). The lightest, narrowest, smallest design is best put at the origin.
- WeightVector, in the font dictionary: an array of k numbers, one for each master, that sum to 1.0 (within 0.001). A font as shipped has one that gives the normal roman design.
- FontInfo keys.
BlendDesignPositions(where each master lies, an array of arrays),BlendDesignMap(for each axis, pairs of design and blend coordinates, which may make the mapping non-linear) andBlendAxisTypes(names such as/Weightand/Width). - Blend dictionary, in the font dictionary:
FontBBoxwith a set of values for each master, and subdictionariesPrivateandFontInfothat hold the entries whose values differ between masters. For the Private blend those can beBlueValues,OtherBlues,StdHW,StdVW,StemSnapH,StemSnapV,BlueScale,BlueShift,FamilyBlues,FamilyOtherBluesandForceBold; for the FontInfo blendUnderlinePosition,UnderlineThicknessandItalicAngle. The ordinary Private and FontInfo then hold the values already blended with the WeightVector. The representation is recursive: a number becomes an array of its k master values, an array becomes an array of the representations of its items, and anything else stays as it is (ForceBoldis excepted). - $Blend, a procedure in the font dictionary, computes the weighted
average
a1 + w2 (a2 − a1) + … + wk (ak − a1)with the WeightVector; OtherSubrs 14 to 18 call it. The font also carries themakeblendedfontemulation, which makes the font dictionary of an instance from a WeightVector.
OtherSubrs 14 to 18
With k masters (the length of the WeightVector, 16 at most), a charstring writes a value as the first master’s value followed by k − 1 differences. The five entries differ only in how many values they blend:
| Entry | Values blended | Arguments (n) | Layout of the arguments |
|---|---|---|---|
| 14 | 1 | k | a1 (a2−a1) … (ak−a1) |
| 15 | 2 | 2k | a1 b1 (a2−a1) … (ak−a1) (b2−b1) … (bk−b1) |
| 16 | 3 | 3k | the three first values, then the differences of a, of b, of c |
| 17 | 4 | 4k | the four first values, then the differences of each in turn |
| 18 | 6 | 6k | the six first values, then the differences of each in turn |
The results come back through pop, the first value first, so
4 14 callothersubr pop blends one value of a four-master font. A font usually wraps
each call in a Subr to save space. Because the stack holds 24 numbers, including the two
arguments of callothersubr, a four-master rrcurveto (six values,
24 numbers) is split into two calls of entry 16 that each return three values, with the
first call’s results left on the stack. The WeightVector is a font dictionary entry, so
the same charstrings draw every instance.
From a design vector to a WeightVector
A user chooses an instance by design coordinates, one for each axis (weight 367, width 450, say), and the font’s two required procedures turn them into the WeightVector (TN 5015, sections 3.8 and 3.9):
- NormalizeDesignVector maps each design coordinate to a blend coordinate
from 0 to 1 through the axis’s
BlendDesignMap: piecewise linearly between its pairs, and held at the end values outside them. - ConvertDesignVector gives each master a weight by simple linear weighting: 1 at that master’s own corner of the space, 0 at every other master, and equal weights in the middle of the space. For masters at the corners the weight of a master is the product, over the axes, of the blend coordinate (where the master is at 1 on that axis) or of 1 minus it (where the master is at 0). The book gives the code for one font (its Appendix D); the viewer uses the general form, which is the same product, and for masters that include intermediate levels on an axis, the linear weight between neighbouring levels.
The masters’ own positions are BlendDesignPositions: in Adobe’s fonts and in the book’s
Myriad example they are blend coordinates ([[0 0] [1 0] [0 1] [1 1]], beside a map from
design 1 to 999). The viewer takes positions that all lie between 0 and 1 as blend coordinates and
anything else as design coordinates to be mapped. The masters must fill a grid (every combination of
the levels of the axes exactly once); a font whose masters do not, or one with no
BlendDesignPositions, is drawn at its stored WeightVector and the viewer says so.
The viewer’s “Design vector” option draws the instance at the coordinates typed for each axis. It then
blends the Private blend dictionary’s entries (BlueValues, StdHW,
BlueScale and the others, by the recursive rule above) with the new weights, so the hinting uses
the values of that instance. Without the option it draws the stored WeightVector, and the option’s boxes start
at the design coordinates that vector corresponds to.
Order in the file
For compatibility with Adobe Type Manager the note asks that BlendDesignPositions,
BlendDesignMap and BlendAxisTypes come before the Blend
dictionary, that the Blend dictionary comes after everything in the font dictionary it can
blend, and that the Private blend comes after the Private entries it blends.
What a reader runs and what it cannot
A Type 1 font carries the PostScript code of its OtherSubrs so that a PostScript
interpreter can run it. A reader that is not a PostScript interpreter does what the book says
about entries it knows (“choosing internal code for the particular functions according to the entry
number”, chapter 8) and, for any other entry, gives the pop commands the arguments back:
the first pop gets the first argument, and extra arguments are dropped.
| Entries | Job | The viewer |
|---|---|---|
| 0 to 2 | Flex | Carries them out: the seven points make two curves, drawn as a line below the flex height when the hints are applied. |
| 3 | Hint replacement | Carries it out: the next stem hints start a new hint set. |
| 12, 13 | Counter control | Carries them out: the data is joined (the call to 13 holds the start of the list) and read into stem groups, which the hinting uses. |
| 14 to 18 | Multiple master blend | Carries them out with the instance’s weights. |
| 4 to 11, 19 and up | Reserved by the book for future extensions | Not run. Each is PostScript, which only a PostScript interpreter can run. The charstring’s pop commands get the arguments, as the book says, and the Dictionaries tab says which entries a font calls and how often. |
The PostScript text of the font’s own OtherSubrs array is shown in the Dictionaries tab and is never
run: the viewer does not contain a PostScript interpreter. Entries 4 to 11 and 19 and up are reserved by the
book; if a font calls one, the viewer shows it as a note, not as a problem.
Sources
Adobe, Adobe Type 1 Font Format (1990; the PDF with the 1993 changes), chapters 8 and 6; Adobe Technical Note #5015, Type 1 Font Format Supplement, 15 May 1994, sections 2 and 3, both read as text from the PDFs.