Files
texrra-engine/docs/NATIVE_FONT_DIAGNOSTICS.md
T

154 lines
9.2 KiB
Markdown

# Native font slots and missing-character diagnostics — 2026-11-01
Subsequent font-state/accent acceptance (2026-11-01): [native font integers and accents](NATIVE_FONT_STATE_ACCENTS.md)
now consumes real first-load defaultskewchar and globally mutable skewchar/
hyphenchar in actual mathaccent/discretionary/hyphenation construction. Full
workspace: 1191 passed / 0 failed, 438 accent DVI geometry and 28 mutable-hyphen
timing cases, a 54-word PDF and full-accent ink gate. Unchanged LaTeX stops at
delimiterfactor (523:1), with full format boot still false. Earlier boundaries,
counts and unimplemented-accent/font-integer notes below are historical.
Route-D now consumes tracinglostchars in actual text, mathematical fetch and
explicit/automatic discretionary construction. A missing TFM character is
omitted with TeX's diagnostic policy. Unsupported fonts, resource sizes,
Unicode shaping or present-but-unsupported text shaping still error. There is
no requested-font substitution, v1/string fallback or template exception.
## Actual resource and encoding state
execution/fonts.rs exposes the actual bundled resource name, OT1/OML/OMS/OMX
encoding, TFM slot presence and Type1 encoding check. The ten resources remain
CMR/CMMI/CMSY 10/7/5 plus CMEX10; font selectors and math families refer to these
real assets. Nullfont has no slots. Presence follows TFM bc/ec and nonzero
width_index, including genuine zero-advance characters; it is not inferred
from Unicode availability, outline aliases, glyph widths or font-name guesses.
A present TFM slot without a Type1 encoding is a resource error, not a missing-
character warning that silently suppresses an unsupported renderer.
The existing iffontchar command now executes real font predicates. Its font
identifier scanner accepts actual selectors/nullfont, current font via font,
and actual textfont/scriptfont/scriptscriptfont families. It validates 0..255
character operands and 0..15 families, expands normal macros/conditionals and
tracks resource/family dependencies. It does not allocate a dummy font or return
an unconditional success. The repeated-CMR10 resource cache retains its real
load-time hyphen character across scoped selectors as before.
Native text remains the CMR10 10pt shaping slice. It now retains each actual
raw slot, so lig/kern processing uses the TFM slot instead of guessing it back
from a Unicode label. All CMR10 slots 0..127 can paint their real encoded glyph,
including char0, char11, char32, char92 and char123. For example OT1 slot92
paints quotedblleft and slot123 endash; Unicode backslash/braces from another
font are not substituted. Measured text nodes send the actual font/slot geometry
to the shared native Type1 painter, without entering math mode or a MathAtom
parser. Missing characters end the ligature chain and still apply real sfcode
default behavior. Missing glyphs never create character nodes or consume width.
PDF ToUnicode maps ff/fi/fl/ffi/ffl to their actual multi-character text, while
retaining one real glyph slot and the same outlines/coordinates. Unmapped slot
labels (for example the suppress slot) remain an explicit metadata limitation;
a metadata replacement label does not paint a replacement glyph.
## Diagnostics and timing
Tracinglostchars and tracingonline are scoped native integer parameters with
actual INITEX defaults 0/0 (57 typed parameters total), arithmetic and quantity
printing. The independently observed pdfTeX INITEX policy is:
| lostchars | online | behavior |
| --- | --- | --- |
| <=0 | any | omit the absent glyph; no diagnostic output |
| 1 | <=0 | transcript only |
| 1 | >0 | terminal and transcript |
| 2 | any | terminal and transcript |
| >=3 | any | terminal/transcript error, fail-stop native job |
Diagnostics use the requested byte's canonical print_ASCII representation,
including protected ^^ strings, real font resource names, uppercase hex on the
fatal path, and TeX's newlinechar behavior. They are emitted at the actual
consumer stage: text construction immediately, mathematical fetch at closing
conversion with the current local fonts/tracing state, and automatic hyphen
construction during the real hyphenation pass. Mathematical fetch clears an
absent nucleus while retaining scripts and ordinary noad spacing; undefined
math families remain strict errors. Missing explicit/automatic hyphen characters
produce the real empty-prebreak discretionary and retain the actual break flag.
Event::MissingGlyph owns font, slot, span, tracing level, destination and message,
including suppressed cases with no output destination. Pure library consumers
can inspect events or attach the optional SourceProvider observer. CLI Files
connects that observer to its actual transcript and stderr terminal channel,
preserving message/write/diagnostic order. Explicit writes still require the
mandatory real I/O interface; the observer is not an empty-I/O implementation.
Host diagnostic failures propagate. Fatal missing glyphs are reported before
the job fails and cannot overwrite the requested existing PDF.
## Acceptance
- Four font integration tests contain **2816 real INITEX slot predicates**
(eleven 256-slot maps including nullfont), four current/family font-identifier
queries, **61 tracing/channel/timing/printer cases**, and **267 dimensions /
missing-count cases**. These cover all CMR10 byte slots, f-missing-i ligature
barriers, math nuclei/scripts/fractions/binary classes, explicit/automatic
missing hyphens, local/global/globaldefs, snapshots, range checks, unsupported
resources and observer failures. Existing token/list/math/packing oracles pass.
- Native and real pdfTeX font diagnostic PDFs both contain one page and **25
words in identical order**. Max word-box errors: xMin 0.005410, xMax 0.005387,
yMin 0.000278 and yMax 0.000078bp, below the unchanged 0.02bp gate.
- An independent **128-slot OT1 grid at 144dpi** verifies absolute per-cell
geometry and ink. Every ink pixel has a counterpart within one pixel, each
bounding box is within one pixel, and total XOR is **19/6010 ink pixels**
(0.316%, under the declared 1% bound). This accounts for subpixel raster edge
coverage without fitting an offset. It is not a pixel-identical claim.
- Complete frozen workspace: **1187 passed / 0 failed**, including 16 CLI tests
(native_execution 12, native_job_io 4). Release, fmt/diff, five prior PDF gates
and math D pass. Math D remains three pages, rule y error +0.1035625bp and
identical 144dpi ink bounds. Prior 58 display vlist/36 page/24 state, 100
interline vlist/64 page, 205 box, 119 paragraph, 117 math geometry/list/88 math
break, 90 token, 101 quantity, 12 filesystem and shipout-I/O oracles remain covered.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_fonts -- --nocapture
cargo test --workspace --offline -- --test-threads=1
cargo build --release --offline
python3 scripts/check-native-font-slots.py --binary target/release/texrra \
--output-dir /tmp/texrra-native-fonts/slots \
--json /tmp/texrra-native-fonts/slots/audit.json
python3 scripts/check-native-paragraphs.py --binary target/release/texrra \
--fixture examples/native-bootstrap/fonts.tex \
--output-dir /tmp/texrra-native-fonts/fonts \
--json /tmp/texrra-native-fonts/fonts/pdf-oracle.json
python3 scripts/probe-native-format.py --binary target/release/texrra \
--texmf /usr/share/texlive/texmf-dist \
--json /tmp/texrra-native-fonts/format-probe-final.json
~~~
Final evidence: /tmp/texrra-native-fonts/ (fonts and slot-grid PDFs/raster,
prior PDF audits, format-probe-final.json and math-regression.json). Final logs:
/tmp/texrra-native-fonts-accepted-workspace.log,
/tmp/texrra-native-fonts-accepted-release.log and
/tmp/texrra-native-fonts-accepted-core.log. Early diagnostic/encoding development
failures are retained separately and are not final acceptance evidence.
## Actual format boundary and remaining work
The unchanged entry-SHA-pinned LaTeX2e 2025-11-01 source now advances past
tracinglostchars at 508 to **latex.ltx:522:1, missing defaultskewchar**. Real
auxiliary timestamp read/write and original directory checks still execute.
format_boot_passed remains false. No guard, format source or version marker
was changed, and defaultskewchar was not registered as unused storage.
Next implement real mutable font integer/metric state and a genuine skew/accent
placement consumer, then continue the untouched format. Do not register a
skew default merely to pass initialization. General font identifiers/resources/
sizes, fontdimen/hyphenchar/skewchar, full ligature/discretionary reconstruction,
TFM/VF/encoding/map closure, NFSS/fd/cls/sty and XeTeX shaping remain required.
Present characters in other bundled fonts still report unsupported native text
shaping rather than pretending the TFM slot is missing. The current mouth's
Unicode-scalar input does not certify pdfTeX UTF-8 byte-input conformance;
byte-font oracles deliberately use explicit char/^^ character codes.
The accepted CM slice does not resolve the transitional template's Nimbus/SFTT
versus Liberation font difference. Native format boot, numbered displays,
remaining math primitives, page/output/shipout/whatsits, full input closure,
dump/load and realtime checkpoints remain open. HTTP/project endpoints have
not migrated; native diagnostics never fall back to the transitional frontend.