Utensil's Zettelkasten-style forest of evergreen notes on math and tech. utensil.tngl.sh/forest/
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(render): iter 108 — revert iter 107's LM-to-CM substitution (caused glyph-index chaos)

Operator visual verdict on iter 107: algpseudocodex blocks in ag-0018
and uts-001F (1st alg) render with 'chaos chars' on the right-hand-side
commands and comments. Root cause: tectonic's XDV emits cmdXGlyphArray
with FONT-SPECIFIC glyph indices into the LM font's glyph table;
redirecting font lookup to cmcsc10.pfb without remapping indices makes
dvisvgm pull wrong characters from CM's table. The pseudo block (2nd
alg) was unaffected by chance — its specific characters happen to map
to the same indices in both font families.

Iter 108: shrink rewrite_dvi.py to ONLY the pdf:pagesize -> xyz:pagesize
replacement (iter 69 baseline). Drop the LM->CM substitution entirely.

Residual difference: tngl uses LM glyph shapes via native XDV references,
gh-pages uses CM via Type1; both render correctly but with slightly
different appearances. The 'space after a/b' collapse in pseudo
block also accepted as residual — not fixable via DVI rewrite (would
require font-aware glyph table remapping for every cm/lm font pair).

Refs #2

[AGENT: kael]

+20 -15
+20 -15
.tangled/workflows/render.yml
··· 513 513 sed -i 's/^ //' /tmp/bin/dvisvgm 514 514 chmod +x /tmp/bin/dvisvgm 515 515 516 - # iter 107 — write the DVI-rewrite python to a real file via printf 517 - # so we don't get bash heredoc / YAML block-scalar interaction issues. 518 - # Single-line printf with %s args inside YAML, no heredoc. 516 + # iter 108 — revert iter 107's font-name substitution. Operator 517 + # confirmed the substitution actually working (verified iter 102's 518 + # state was a no-op due to indentation bug) causes a regression: 519 + # algpseudocodex blocks render with wrong glyph indices (chaos 520 + # chars). Root cause: tectonic's XDV cmdXGlyphArray emits 521 + # FONT-SPECIFIC glyph indices into the LM glyph table; redirecting 522 + # to a CM PFB without remapping the indices makes dvisvgm draw 523 + # different chars. The pseudo block was unaffected only because 524 + # its specific LM fonts happen to have aligned indices for the 525 + # characters in use. 526 + # 527 + # Write a no-op rewrite_dvi.py — just the pdf:pagesize replacement 528 + # (iter 69). Drop the LM-to-CM substitution. The residual difference 529 + # between tngl and gh-pages is now ACCEPTED: tngl uses LM glyphs 530 + # via native XDV references, gh uses CM via Type1; both render but 531 + # with slightly different shapes. The space-collapse complaint is 532 + # also accepted as residual — not fixable via DVI rewrite (would 533 + # need DVI glyph-index remapping, which requires font-aware 534 + # cm-to-lm glyph table mapping). 519 535 printf '%s\n' \ 520 536 'import sys' \ 521 537 '' \ ··· 523 539 'with open(p, "rb") as f:' \ 524 540 ' d = f.read()' \ 525 541 'd2 = d.replace(b"pdf:pagesize", b"xyz:pagesize")' \ 526 - 'subs = [' \ 527 - ' (b"lmromancaps10-regular", b"cmcsc10\0\0\0\0\0\0\0\0\0\0\0\0\0\0"),' \ 528 - ' (b"lmroman10-italic", b"cmti10\0\0\0\0\0\0\0\0\0\0"),' \ 529 - ']' \ 530 - 'hits = []' \ 531 - 'for lm, cm in subs:' \ 532 - ' if len(lm) == len(cm) and lm in d2:' \ 533 - ' hits.append(lm.decode("ascii", "replace"))' \ 534 - ' d2 = d2.replace(lm, cm)' \ 535 542 'if d2 != d:' \ 536 543 ' with open(p, "wb") as f:' \ 537 544 ' f.write(d2)' \ 538 - 'with open("/tmp/iter106-shim.log", "a") as logf:' \ 539 - ' logf.write(" py ran size_d={} size_d2={} hits={}\n".format(len(d), len(d2), hits))' \ 540 545 > /tmp/bin/rewrite_dvi.py 541 546 chmod +x /tmp/bin/rewrite_dvi.py 542 - echo " ✓ wrote /tmp/bin/rewrite_dvi.py ($(wc -l < /tmp/bin/rewrite_dvi.py) lines)" 547 + echo " ✓ wrote /tmp/bin/rewrite_dvi.py ($(wc -l < /tmp/bin/rewrite_dvi.py) lines) — iter 108 no-LM-sub variant" 543 548 544 549 # Sanity: shim takes precedence over any latex/dvisvgm that nixery might provide. 545 550 echo "latex resolves to: $(command -v latex)"