Skip to content

Surface silent PDF rendering loss: gate dropped glyphs, report overflow, fix \setminus#103

Merged
asluk merged 2 commits into
mainfrom
wip/glyph-fallback-and-ci-report
Jun 30, 2026
Merged

Surface silent PDF rendering loss: gate dropped glyphs, report overflow, fix \setminus#103
asluk merged 2 commits into
mainfrom
wip/glyph-fallback-and-ci-report

Conversation

@asluk

@asluk asluk commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Two changes to stop the PDF build from silently dropping content from the rendered output. The PDF opens fine — but individual glyphs go missing from the math with no error surfaced, so a downstream spec build shipped with missing symbols unnoticed.

1. PDF quality gate (#100)

doc_builder.py's stderr filter previously suppressed every Overfull \hbox warning and let Missing character warnings scroll past without failing the build. So right-margin overflow and silently-dropped glyphs were both invisible in CI.

New behavior in the stderr_processor + a new _report_pdf_diagnostics helper:

  • Missing-character / unrepresentable-glyph → FAILS the build by default. A character silently vanishing from the PDF is meaning-changing, so it should hard-fail. --no-check-glyphs downgrades to a warning.
  • Overfull \hbox (Xpt too wide) → collected and REPORTED, worst-first, non-fatal by default. --check-overflow makes them fatal; --overflow-threshold-pt sets the cutoff (default 1.0).
  • Underfull boxes still ignored.

Sample output:

[doc_build] Right-margin overflow: 185 line(s) exceed the text width by >= 1.0pt (worst 172.3pt):
[doc_build] PDF diagnostics reported above (non-fatal).

# silently-dropped glyph -> build FAILS:
[doc_build] Missing glyphs (silently dropped from the PDF): 6 warning(s) [U+29F5 x6]
[doc_build] PDF quality gate failed (aousd/doc_build#100):
  - 6 missing-glyph warning(s) -- characters were silently dropped from the PDF

2. \setminus remap (template/after-header-includes.latex)

unicode-math maps \setminusU+29F5 (reverse solidus operator), which no bundled math font provides — DejaVuMathTeXGyre and latinmodern-math both lack it, and tectonic's bundle ships only latinmodern-math.otf as an OTF math font. Result: \setminus renders as a blank/tofu box. Remapped to U+2216 (standard set-minus), which DejaVuMathTeXGyre has:

\renewcommand{\setminus}{\mathbin{\char"2216}}

Minimal repro (blank before, set-minus after):

$A \setminus B$

This is purely an engine/font-coverage gap, so it belongs here. (A separate, source-level issue — a text-mode \^ accent misused in math mode, which drops the accent — is fixed in the downstream spec source, not here.)

Validation

Built a downstream spec against this branch (local Windows + Linux CI, byte-identical PDFs): 0 missing-glyph warnings after the fix; set-minus renders. Validated in CI both directions: a clean build passes; a deliberately-reintroduced missing glyph fails the build (gate message + exit 1) with overflow staying non-fatal — so the build fails only on the dropped glyph, as designed. Before/after renders available on request.

Decisions for maintainers (@OleksiyPuzikov @dgovil)

This touches every spec's CI, so the defaults are a policy call:

  1. Hard-fail on dropped glyphs for all specs — reasonable as the default? (My take: yes — a vanished character is never intended.)
  2. Overflow threshold / default-non-fatal — currently report-only at >= 1.0pt. Honest but noisy (~185 lines), largely from RaggedRight + wide math. Keep non-fatal default, or pick a higher threshold?
  3. Interacts with [ISO] Change from ragged-right margin to right-justified #11 (ragged-right → justified): switching to justified changes overflow behavior, so the threshold here should be coordinated with that work.
  4. Re Debug the LaTeX handling of Windows paths in the font setup #23 (Windows font paths in font setup): hit exactly this during validation — absolute C:/ font paths break fontspec; the existing relative posix dejavufontpath workaround is what makes it build. Confirms Debug the LaTeX handling of Windows paths in the font setup #23's root cause; nothing here depends on changing it.

…ow, fix \setminus

Two changes so the PDF build stops silently dropping content from the
rendered output. The PDF opens fine, but individual math glyphs go missing
with no error surfaced -- so a downstream spec build shipped with missing
symbols unnoticed.

1. PDF quality gate (#100). The stderr filter previously suppressed every
   Overfull \hbox warning and let "Missing character" warnings scroll past
   without failing the build. Now:
     - Missing-character / unrepresentable-glyph warnings FAIL the build by
       default (a silently dropped character is meaning-changing);
       --no-check-glyphs downgrades to a warning.
     - Overfull \hbox (Xpt too wide) are collected and REPORTED worst-first,
       non-fatal by default; --check-overflow makes them fatal,
       --overflow-threshold-pt sets the cutoff (default 1.0pt).
     - Underfull boxes still ignored.

2. \setminus remap. unicode-math maps \setminus to U+29F5 (reverse solidus
   operator), which no bundled math font provides (DejaVuMathTeXGyre and
   latinmodern-math both lack it; tectonic ships only latinmodern-math.otf).
   It rendered as a blank box. Remapped to U+2216 (standard set-minus),
   which DejaVuMathTeXGyre has.

Resolves #100.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dgovil
dgovil self-requested a review June 30, 2026 21:54
The diff self-test invokes the builder with a types.SimpleNamespace args
object that has none of the new gate flags, so args.no_check_glyphs raised
AttributeError. Read the three flags via getattr, and define their defaults
as module-level constants (GATE_DEFAULT_*) referenced by both the argparse
`default=` and the getattr fallbacks -- single source of truth, so the CLI
and programmatic-caller paths cannot drift apart.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@asluk
asluk force-pushed the wip/glyph-fallback-and-ci-report branch from 1fc048c to b517fff Compare June 30, 2026 22:36
@asluk
asluk merged commit 4a60a36 into main Jun 30, 2026
1 check passed
@asluk
asluk deleted the wip/glyph-fallback-and-ci-report branch June 30, 2026 22:54
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.

2 participants