Documentation
¶
Overview ¶
Package sfnttest builds a font file byte by byte.
A test that needs a real font needs either a binary nobody can review or a font whose every byte the test wrote itself, and this is the second. It is a package rather than a test file because two packages need it — the parser and subsetter in internal/sfnt, and the PDF backend that embeds what they produce — and a font builder copied into both would be two fonts that drift.
Four glyphs, one of them a composite, and a cmap in whichever of the two supported formats the caller asks for. It is enough to exercise the table directory, the metric tail, the composite closure and the glyph renumbering, and small enough that a failure names a byte rather than a font.
Index ¶
Constants ¶
const ( UnitsPerEm = 1000 NumGlyphs = 4 )
The design grid and the glyph count of the font this package builds.
const ( GlyphNotdef = 0 GlyphA = 1 GlyphB = 2 GlyphComp = 3 )
The glyphs: 0 is .notdef and empty, 1 and 2 are simple triangles, 3 is a composite of 1 and 2 — which is what makes the subset's closure and its renumbering testable at all. GlyphA is reached by 'A', GlyphB by 'B' and GlyphComp by 'Ä'.
Variables ¶
var Advances = [NumGlyphs]uint16{500, 600, 700, 650}
Advances is the advance width of each glyph, in font units.
Functions ¶
func CFFFont ¶
func CFFFont() []byte
CFFFont builds a font whose outlines are CFF charstrings rather than glyf entries — an `.otf`, in the shape a reader meets one.
The CFF table's contents are a placeholder, and deliberately: nothing in figure interprets charstrings. What such a font exercises is the half that is figure's own — that the format is recognised, that it is reported as unsubsettable, and that the PDF wrapper written around it is the CID font a CFF program belongs in rather than the one a glyf program does.
func Cmap4 ¶
func Cmap4() []byte
Cmap4 maps 'A' and 'B' to glyphs 1 and 2 and 'Ä' to the composite, in the segmented format every Windows font carries.
func Cmap12 ¶
func Cmap12() []byte
Cmap12 is the same mapping in the flat format a font needs to reach past the Basic Multilingual Plane, plus one code point that actually is past it.
Types ¶
This section is empty.