On 10/6/2026 1:07 AM, Dax Kelson wrote:
Hi Hans,
Thanks for looking. You saw no difference for three reasons, and two of
them are my fault...apologies.
1. The test files. In LMTX they made a 3.1 pt wide page, so the glyphs
fell off the page. The corrected files are attached.
i already put a dontleavehmode in front
2. The viewers. I was wrong to suggest okular and pdftoppm. I rendered
the unhinted and the hinted PDF at 96 dpi:
- Poppler (pdftoppm, okular): identical pixels. It ignores the hints by
default.
- MuPDF (sumatra): identical with anti-aliasing on, the default.
Different with anti-aliasing off.
- Ghostscript: different.
To see it: gs -sDEVICE=png16m -r96 -dTextAlphaBits=4 -o out.png file.pdf
i know that there are issues on linux (it's why jim still uses acrobat)
3. Your screen. At high resolution hinting hardly shows.
So hints matter only where the renderer uses them: Ghostscript and the
print workflows built on it. That is a smaller audience than my first
mail suggested. I offer the patches anyway, in case they are useful.
Take both, only the TrueType one, or neither.
Ok, but todays printers are more or less high res, aren't they? Toner
particles and ink drops and paper are more of an issue.
The patches are against 29a331b (the 2026.10.01 upload).
i'll look at it tomorrow .. in the meantime i adapted the t1 cff loader
(it's an a typical font, the old bitstream) and seac and will send you
those files (wipe the cache)
ttf-hints.diff (+70/-15), \enabledirectives[fonts.truetype.keephints],
off by default:
- keeps cvt, fpgm and prep, and the instructions of simple glyphs;
- leaves variable fonts and instances alone (nothing changes when the
font has gvar or fvar, or for an instance);
- keeps composites flattened as now, so MetaPost outlines and subsetting
work as you want. A flattened composite loses its instructions;
- adds "hinted" to the shapes cache hash, so hinted and unhinted shapes
never mix.
t1-hints.diff (on top of the TrueType one),
\enabledirectives[fonts.type1.keephints], off by default:
- keeps hstem and vstem in the charstrings (hstem3 and vstem3 become
three plain stems);
- turns hint replacement (othersubr 3) into a hintmask where the new set
of stems starts;
- passes the PFB's Private dictionary hint keys to the existing CFF
writer: the blue zones, StdHW/StdVW, the stem snaps and ForceBold.
FreeType then hints the CFF exactly as it hints the PFB: no bitmap
differs over all 821 glyphs of lmr10 at 5 to 48 ppem. A glyph with more
than 96 stems over all its sets (the Type 2 limit) stays unhinted:
LibertinusT1Math's peseta has 108. Counter control (othersubrs 12 and
13), dotsection and seac are left as they are now.
The two images show 96 dpi with hinting. ttf-hints-96dpi.png: pdfTeX,
LMTX now, LMTX with the patch. freetype-hinted-t1-96dpi.png: the PFB,
LMTX now, LMTX with the patch.
One bug that has nothing to do with hints. In lpdf-emb.lmt, makefontfile
writes checkSumAdjustment at
local off = #list[1] + headof + 1 + 8
but headof is already a file offset that includes the table directory.
So the four bytes land past head, in the next table. With the current
table set that is maxp: for DejaVu Sans, maxStackElements and
maxSizeOfInstructions read 37551 and 45156 (the real values are 1045 and
534). With more tables after head it hits loca, and fontTools can no
longer read glyf. The fix is one line:
local off = headof + 1 + 8
It is in ttf-hints.diff, but it stands on its own.
If you would rather not take them, point 1 of my first mail would let us
keep this in our own code: would you accept
lpdf.registerfontwriter(format, writer), and exported widtharray,
tounicodedictionary and the registry/metadata helpers?
A small one we noticed on the way: every Type 2 charstring converted
from Type 1 ends with closepath endchar (bytes 09 0e). Operator 9 is
reserved in Type 2. FreeType ignores it, but fontTools will not
recompile those charstrings.
Dax
On Mon, Oct 05, 2026 03:41 PM, Hans Hagen via ntg-context <ntg-
[email protected] <mailto:[email protected]>> wrote:
On 10/5/2026 9:12 PM, Dax Kelson via ntg-context wrote:
> Hi Hans,
>
> Two test files are attached. Both use free fonts from TeX Live,
so they
> run as they are:
>
> - hints-ttf.tex: DejaVu Sans (TrueType, hinted; the accented
letters are
> composite glyphs).
> - hints-t1.tex: Latin Modern Roman 10, lmr10.pfb (Type 1, hinted; it
> uses subroutines, hint replacement and flex).
i just looked at the ttf rendering and see nothign bad, but sumatra
(mupdf) and okular on windows are quite ok
one problem, with hints is that now that we have variable fonts, we
also
need to deal with these
> Each prints the same 32 glyphs at 6.25, 9.375 and 12.5 bp, every
glyph
> at a fixed position, so LMTX and pdfTeX put each glyph in exactly
the
> same place and only the embedded font differs. Run each with
context,
> and with pdftex for comparison (the first lines of each file say
how).
> Then look at both PDFs at 100% in a viewer that uses FreeType
hinting
> (evince, okular, or pdftoppm at 96 dpi). With pdfTeX the stems
snap to
> whole pixels; with LMTX the glyphs are unhinted and look softer and
> uneven at these sizes.
hm, looks ok here (ok, i have a relative high res sceen)
> What we do in our setup now, which an option could do in LMTX:
> - TrueType: keep cvt, fpgm and prep (and PCLT), keep the glyph
> instructions, and keep composite glyphs as composites, as
writettf.c does.
> - Type 1 to CFF: keep the hstem/vstem hints (with hint
replacement) in
> the charstrings, and copy the hint keys of the Private dictionary
> (BlueValues, OtherBlues, BlueScale, BlueShift, BlueFuzz, StdHW,
StdVW,
> StemSnapH, StemSnapV).
>
> If you want, we can send a patch for either one, behind an option
that
> is off by default.
well, i can have a look, but don't want to complicate code too much
the composed char is the first look look at; we don't keep 'm as
composites (which is just a space optimization) is that we also want
outlines in mp and subsetting works better too
Hans
% wipe streams cache for tracing
\enabletrackers[fonts.cff.charstrings]
\starttext
\definecolor[ColorA][r=1,a=1,t=.5]
\definecolor[ColorB][r=g,a=1,t=.5]
\definefontfeature[xx][default][pfbfile=lmr10.pfb]
\startTEXpage[offset=0pt]
\startoverlay
{\ColorA\definedfont[file:lmr10.afm*xx @
10pt]test}
{\ColorB\definedfont[file:lmroman10-regular.otf*xx @
10pt]test}
\stopoverlay
\stopTEXpage
\stoptext
backend > fonts > start embedded fonts
backend > fonts > 1 : file 'lmr10.pfb', base
'XHTVJR+LMRoman10-Regular', instance 'lmr10pfb-0-0-0'
backend > fonts > 2 : file 'lmroman10-regular.otf', base
'SNRPFF+LMRoman10-Regular', instance 'lmroman10regularotf-1-0-0'
backend > fonts > stop embedded fonts
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl <http://www.pragma-
ade.nl> | www.pragma-pod.nl <http://www.pragma-pod.nl>
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an
entry to the Wiki!
maillist : [email protected] <mailto:[email protected]> / https://
mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl <https://
mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl>
webpage : https://www.pragma-ade.nl <https://www.pragma-ade.nl> /
https://context.aanhet.net <https://context.aanhet.net> (mirror)
archive : https://github.com/contextgarden/context <https://
github.com/contextgarden/context>
wiki : https://wiki.contextgarden.net <https://
wiki.contextgarden.net>
___________________________________________________________________________________
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________