Skip to content

Draw text - #3

Merged
tannevaled merged 1 commit into
mainfrom
text
Aug 25, 2026
Merged

tannevaled merged 1 commit into
mainfrom
text

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The other half of a page. The whole text state — face, size, character and word
spacing, horizontal stretch, leading, rise and rendering mode — every
positioning operator, and every way of showing a string including the array
whose numbers move the pen between pieces.

Glyphs come from three places, which is what the corpus needs. An embedded
TrueType or OpenType program, addressed through the font's own character map
for a symbolic font and through an encoding of glyph names otherwise, with the
Differences list a file may write over either. A composite font, addressed two
bytes at a time by character identifier, with the widths named singly or in
runs and a map from identifiers to glyphs. And a Type 3 font, whose glyphs are
little content streams — which this package already knows how to run, so they
are simply run, in the state that showed them and under the font's own matrix.

A font whose program cannot be read draws nothing but still advances the pen by
the widths the file states, so everything after the text stays where it
belongs. That is the difference between a page missing its letters and a page
that has fallen apart.

Checked by drawing text and looking at it: a capital H at forty points on a
baseline at ten has to put ink above that line and none below it, and none
before where the text begins. A Type 3 glyph that fills its own em becomes a
square from (10,10) to (30,30) at twenty points, which is exact enough to catch
a font matrix applied the wrong way round. Spacing, stretch, rise, the four
rendering modes and the widths of a composite font are each pinned by where
they leave the last glyph.

The measured effect on the corpus: pages that come out blank fall from 31 to 26
of 4 108. The number is small because images already carried most pages; what
text changes is what is on the ones that were not blank.

Exact 100% statement coverage, go vet clean, nine cross-compilation targets.

The other half of a page. The whole text state — face, size, character and word
spacing, horizontal stretch, leading, rise and rendering mode — every
positioning operator, and every way of showing a string including the array
whose numbers move the pen between pieces.

Glyphs come from three places, which is what the corpus needs. An embedded
TrueType or OpenType program, addressed through the font's own character map
for a symbolic font and through an encoding of glyph names otherwise, with the
Differences list a file may write over either. A composite font, addressed two
bytes at a time by character identifier, with the widths named singly or in
runs and a map from identifiers to glyphs. And a Type 3 font, whose glyphs are
little content streams — which this package already knows how to run, so they
are simply run, in the state that showed them and under the font's own matrix.

A font whose program cannot be read draws nothing but still advances the pen by
the widths the file states, so everything after the text stays where it
belongs. That is the difference between a page missing its letters and a page
that has fallen apart.

Checked by drawing text and looking at it: a capital H at forty points on a
baseline at ten has to put ink above that line and none below it, and none
before where the text begins. A Type 3 glyph that fills its own em becomes a
square from (10,10) to (30,30) at twenty points, which is exact enough to catch
a font matrix applied the wrong way round. Spacing, stretch, rise, the four
rendering modes and the widths of a composite font are each pinned by where
they leave the last glyph.

The measured effect on the corpus: pages that come out blank fall from 31 to 26
of 4 108. The number is small because images already carried most pages; what
text changes is what is on the ones that were not blank.

Exact 100% statement coverage, go vet clean, nine cross-compilation targets.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@tannevaled
tannevaled merged commit 50bc5cb into main Aug 25, 2026
1 check passed
@tannevaled
tannevaled deleted the text branch August 25, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant