Repository navigation
Description
TrueTypeFontEmbedder.cs:185:
.Set(new Core.PdfName("StemV"), new Core.PdfInteger(80)) // heuristicEvery font this library embeds gets /StemV 80. The comment is honest about it, which is better than
pretending, but the value is wrong for every font that is not a regular-weight text face — a light
face, a bold face and a display face all get the same stem width.
Why it is not cosmetic
/StemV is a required font descriptor entry, and it is what a reader uses to synthesise a substitute
when the embedded program is unavailable or when rendering at very small sizes. A wrong value produces
a substitute of visibly wrong weight. PDF/A requires the entry be present; nothing requires it be
true, which is exactly why it drifts.
Approaches, cheapest first
- From
OS/2weight class —usWeightClass(100–900) maps to a plausible stem width range. The
table is already parsed; this is arithmetic. Crude but strictly better than a constant. - Measured from the glyph outlines — the conventional approach is to measure the vertical stem of
a known glyph such asIorlin theglyfor CFF charstrings. More accurate, more work, and it
needs care for fonts lacking those glyphs.
Approach 1 is a clear improvement and can land first; 2 is a refinement worth noting in the issue but
not blocking on.
Acceptance
- A light, regular, bold and black weight of the same family produce four different
/StemVvalues,
ordered correctly. - A font with no
OS/2table still produces a defensible value rather than throwing. - Existing documents' output changes only in
/StemV— asserted by diffing, so the change is provably
contained.
Relates to
- C5 — the other thing
OS/2is parsed for and then not used properly.
Plan labels used above, resolved: C5 #267.
Activity