Advance native LaTeX execution and preview

This commit is contained in:
gloamxun committed 2026-11-18 22:17:21 +08:00
1 parent 91f9d76b16
commit 2741546ca8
414 files changed
+99872 -933

No files matched your search

+170
View File
@@ -0,0 +1,170 @@
# Native font integer state and math accents — 2026-11-01
Subsequent box/list diagnostic acceptance (2026-11-01): [native inspection](NATIVE_BOX_DIAGNOSTICS.md)
consumes actual showboxbreadth/showboxdepth and original nodes/settings in real
log/terminal output. Full workspace: 1200 passed / 0 failed; 152 exact recursive
lists, 24 paragraph lists, 24 byte-printer cases, 17 CLI tests and five-show/
19-word PDF gate pass. Unchanged LaTeX stops at errorcontextlines (526:1), full
startup false. Compound math/glue inspection and full interaction remain open.
Earlier counts/boundaries below are historical; no font/template fidelity claim.
Subsequent delimiter acceptance (2026-11-01): [native delimiter fields and construction](NATIVE_DELIMITERS.md)
now consumes real delcodes, left/right fields, factor/shortfall and actual TFM
variants/extensible recipes. Full workspace: 1195 passed / 0 failed; 452 exact
DVI cases, code/group readbacks, a 61-word PDF and full-delimiter ink gate pass.
Generic odd-sp fraction/reboxing rounding is corrected. Unchanged LaTeX stops
at showboxbreadth (524:1), full startup false. Earlier counts, boundaries and
unimplemented-left/right/delimiter notes below are historical.
The strict Route-D token executor now consumes defaultskewchar in real font
loading and skewchar in native mathaccent construction. It implements mutable
hyphenchar through actual discretionary/hyphenation consumers. No font
substitution, v1/string fallback, template rule or runtime TeX process is used.
## Resource identity, state and timing
TextFont identifies the actual bundled font, independent of its mutable
integers. FontIntegers belongs to the loaded resource, persists when a local
selector goes out of scope, and is reused by repeated loads of the same actual
resource/design size. All ten real CM masters and nullfont have their own
integer state. Defaultskewchar adds one consumed typed integer parameter (58
total); it has local/global/globaldefs behavior, arithmetic and quantity
printing, just like defaulthyphenchar.
Actual INITEX defaults are defaultskewchar=0 and defaulthyphenchar=0; nullfont
starts with skewchar=-1 and hyphenchar=45. On a first real load the current
scoped defaults are copied to resource integers. Changing defaults afterwards
does not change already loaded resources. The convenience non-INITEX bootstrap
still has its existing preloaded CMR10 policy; it is not an INITEX claim.
Font integer assignments are strictly global in TeX: braces, negative globaldefs
or absence of a global prefix do not restore skewchar/hyphenchar. Font selectors
and math-family assignments remain scoped. Both commands use actual font
identifiers (selectors, current font and three-size math families), support
internal integer scanning/the/number/ifnum/expressions, and enforce integer
capacity. They are not count registers: advance/multiply/divide of these font
integers is rejected. Source and font/resource dependencies remain recorded;
these coarse dependencies do not authorize incremental cache reuse.
Explicit discretionary construction consumes the actual current resource's
hyphenchar immediately. A literal hyphen's discretionary status is fixed at
character construction; pending material is completed before font integer
mutation. Automatic hyphenation reads the font's current hyphenchar during the
real paragraph hyphenation pass, even if it changed after the input characters.
Negative/out-of-byte values disable hyphens; absent TFM slots use the existing
real missing-character diagnostics and empty-prebreak discretionary behavior.
Present discretionary characters in other, unsupported text fonts error rather
than being rendered using CMR10. General text shaping remains the CMR10 slice.
## Native mathaccent
Mathaccent scans a real 15-bit math character code, applies the actual fam
selection rule, creates an owned accented noad and scans its nucleus as a math
field. Macro aliases, grouped fields, scripts, styles and existing native
fraction/list execution retain their usual token and save-stack semantics.
There is no source recognizer or MathAtom adapter.
At actual math-to-horizontal conversion:
- Fetch the accent through its actual family/size. If absent, report its genuine
slot and retain ordinary nucleus/scripts, including character versus trailing
italic-kern visibility for pre-display sizing. Missing nuclei still clear
correctly; undefined families/unsupported resources remain errors.
- Read skewchar from the base character's actual font, not the accent font or
current text selector. Use the actual TFM lig/kern pair for the skew amount;
no geometric guess, outline slant or fixed offset is added.
- Clean the nucleus in cramped style. Follow actual TFM next-larger tags while
the candidate advance fits the original nucleus width; retain real CMEX slots
and the 10/7/5pt masters. Use actual accent-font x-height for vertical overlap.
- For a single-character nucleus with scripts, move those scripts into the
cleaned nucleus as TeX does. Keep the original unscripted width for centering
and variant selection. Grouped/list nuclei keep their distinct script rule.
- Form the zero-width shifted accent and measured vertical geometry, preserving
final width/depth and the minimum original height. Freeze raw font/slot
geometry for boxes, paragraph/display placement, SVG and PDF.
Actual Type1 accent glyph names now supply Unicode metadata, including CMR
circumflex and CMEX wide variants, and the OML combining vector. The painter
continues to use original resource slots; no placeholder glyph is painted.
This improves actual extraction but does not promise full encoding metadata.
In particular the reference PDF without ToUnicode exposes some wide accents as
legacy ASCII and the vector as tilde; the native output does not imitate those
incorrect letters. General symbol/extension descriptors and ToUnicode closure
remain open. The complete accent fixture therefore has a separate ink gate;
matching-Unicode text has its own unchanged 0.02bp word-box gate.
## Acceptance and independent evidence
Four new integration tests in execution_font_state.rs cover:
- Exact INITEX default/global mutation/load-reuse/current-family identifier and
integer-scan readback. Six composite message comparisons include nullfont,
local selector lifetime, negative globaldefs, macro aliases and integer bounds.
- **438 actual INITEX accent cases**: widths/heights/depths and every raw-font
glyph/rule DVI position agree within **1sp**. This includes text/display/
script/scriptscript styles, six skew values, scalar versus grouped nuclei,
scripts, nested accents, fractions, wide variants, fam override, missing
accent/base slots and late assignments. scripts/native-math-dvi-oracle.py
reads actual DVI and reference TFM data; it imports no native geometry.
- **28 mutable hyphenchar cases** compare dimensions and missing counts for
explicit/literal/automatic construction, before/after assignments, out-of-byte
values and actual paragraph completion. These supplement the existing 267
raw-slot/math/discretionary cases, not replace them.
- Frozen owned noads/serialization, dependencies and strict malformed-code,
missing-field/font, unsupported shaping/resource and arithmetic failures.
Complete frozen workspace: **1191 passed / 0 failed**, including the existing
16 CLI tests. Release, fmt/diff and all previous native/Math D gates pass.
The new accent-text.tex native/reference PDFs both have **one page / 54 words
in identical order**, with max errors xMin 0.004606, xMax 0.005105,
yMin 0.000278 and yMax 0.000078bp under the unchanged 0.02bp gate.
The full accents.tex includes actual CMEX wide accents and the OML vector.
Its 144dpi comparison passes absolute positions/ink coverage and matching
bounding boxes [144,142,547,312]. XOR is **35/7673 reference ink pixels
(0.456%, below the declared 1%)**; no unmatched pixel is farther than one
pixel in either direction. No offset is fitted; this is not pixel identity.
Both text and full-accent rasters were visually inspected.
Prior 2816 slot predicates + four queries, 61 tracing cases, 267 raw-slot cases,
128-slot raster, 58 display vlist/36 page/24 state, 100 interline vlist/64 page,
205 box, 119 paragraph, 117 math list/88 break, 90 token, 101 quantity,
12 filesystem and shipout-I/O/pack-state oracles remain green. Existing math D:
three pages, rule y error +0.1035625bp, identical 144dpi formula ink bounds.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_font_state -- --nocapture
cargo test --workspace --offline -- --test-threads=1
cargo build --release --offline
python3 scripts/check-native-paragraphs.py --binary target/release/texrra \
--fixture examples/native-bootstrap/accent-text.tex \
--output-dir /tmp/texrra-native-skew/accent-text \
--json /tmp/texrra-native-skew/accent-text/pdf-oracle.json
python3 scripts/check-native-accents.py --binary target/release/texrra \
--output-dir /tmp/texrra-native-skew/accents \
--json /tmp/texrra-native-skew/accents/audit.json
~~~
Final evidence: /tmp/texrra-native-skew/ contains accepted-core.log,
accepted-workspace.log, accepted-release.log, accepted-cli.log, final PDFs,
raster and audit JSON, format-probe-final.json and math-regression.json.
Early failed tests (fixture filename whitespace and newly implemented negative
boundary) and exploratory wide-accent text comparisons remain separate; they
are not reported as passing word-box gates.
## Actual format boundary and next work
The unchanged entry-SHA-pinned LaTeX2e 2025-11-01 now passes defaultskewchar at
522 and stops at **latex.ltx:523:1, missing delimiterfactor**. Actual auxiliary
time/date I/O and original directory tests still run. format_boot_passed=false;
no format source, capability guard or version constant was altered.
Next implement native delimiter sizing and left/right/delimiter fields using
actual delcodes, delimiterfactor/delimitershortfall and TFM variant/extensible
recipes. These parameters need real consumers, never inert initialization.
General mutable fontdimen, arbitrary resources/sizes/VF/map/NFSS, text accents,
full ligature/reboxing reconstruction, operator limits, numbered displays,
alignments, page/output/shipout/whatsits, full format closure/dump/load and
realtime checkpoints remain open. The Unicode-scalar mouth still does not
certify pdfTeX UTF-8 byte input. HTTP/project routes have not migrated; the
transitional Nimbus/SFTT versus Liberation template font gap remains.