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

+132
View File
@@ -0,0 +1,132 @@
# Native paragraph-to-vlist interline penalties — 2026-11-01
Subsequent font-slot acceptance (2026-11-01): [native font diagnostics](NATIVE_FONT_DIAGNOSTICS.md)
now consumes tracinglostchars/tracingonline using actual TFM/Type1 slots, with
real font predicates, log/terminal delivery and fatal PDF protection. Full
workspace: 1187 passed / 0 failed; prior slice gates remain green. Unchanged
LaTeX now stops at defaultskewchar (522:1), so earlier boundaries/counts on
this page are historical. Full format startup remains false.
Current follow-up (2026-11-01): [native display math](NATIVE_DISPLAY_MATH.md)
is accepted: 1182 workspace tests, 58 vlist / 36 page / 24 quantity-mode-pack
cases and a three-page PDF gate. Unchanged LaTeX now stops at tracinglostchars
(508:1). Earlier counts/boundaries below describe their original slices.
Route-D now generates interline, club, widow and broken penalties from the
actual native line-breaking result. The existing strict native PDF path passes
these owned vertical nodes into the shared PageBuilder. No source string,
template adjustment, inert parameter registration or v1 dispatch is involved.
## State and construction
The four new integer parameters have genuine INITEX zero defaults and use the
native scoped save stack, global/globaldefs assignments, integer arithmetic,
reading/printing and dependency keys. They are read at paragraph completion,
not at paragraph start or from the final document state. Together with the
previous slices there are now 45 typed paragraph/math/layout parameters.
NativeParagraph retains discretionary_breaks for each selected line and the
summed interline_penalties for each gap. A chosen discretionary break carries
its real flag independently of the painted hyphen character; explicit/literal
and automatically inserted discretionary nodes use the same path. The end-of-
paragraph break is not a discretionary break for this purpose.
After every nonfinal line, post-line-break sums:
- interlinepenalty;
- clubpenalty after the first line;
- widowpenalty before the final line;
- brokenpenalty when that line actually ended at a discretionary break.
A two-line paragraph therefore receives both club and widow terms. Zero sums
produce no penalty node. Nonzero values are preserved, including negative,
forced and >=10000 values; they are not individually clamped before addition.
A sum outside the native signed integer capacity fails explicitly.
The penalty is appended after the measured line box and before append-to-vlist
adds the next baseline/line glue. It does not modify prevdepth or line metrics.
The result is frozen into VerticalMaterial, or into the containing vbox/vtop.
Stored/copied nested boxes retain penalties but are indivisible page material;
internal penalties do not ship their contents as independent pages.
## Actual pagination and export
Execution.document exports the already-built native lists, including their
penalties, into measured Document units. Native paragraph penalties are not
reconstructed from document-wide club/widow defaults. The native CLI uses
Engine::layout_paged directly and rejects unsupported material; it never falls
back to a greedy renderer or v1. PageBuilder consumes the same explicit penalty
nodes that the PDF/display export lays out.
The new page-ownership oracle exposed an existing general cost error: with
badness=10000, TeX uses the fixed deplorable cost 100000 instead of adding a
finite penalty. Correcting that rule prevents finite club/widow values from
incorrectly distinguishing saturated underfull candidates. Forced break cost
records its actual penalty. The existing finite-badness penalty regression now
provides stretch before both competing breakpoints so that it tests a real
finite-badness choice. Page costs are distinct from hpack/vpack last_badness.
This is a tested ordinary paragraph/list page-consumer slice, not complete
TeX page/output execution. Page goal/topskip/maxdepth/paper/origin still come
from the explicit host canvas policy. Strict native vsize/topskip/maxdepth,
box255/output/shipout, insert/mark/whatsit execution, full page cost/capacity and
all glue/kern/float corner cases remain product work. The page-ownership oracle
sets the reference's real canvas parameters explicitly; no fake primitive is
registered. Document pagination is not a resumable native page checkpoint.
## Acceptance
- Four integration tests contain **100 real pdfTeX INITEX vlist cases**, including
**132 selected discretionary breaks**, and **64 actual page-ownership cases**.
Coverage includes one/two/many lines, summed/zero/negative/prohibited/forced
values, first/final-line boundaries, explicit/automatic/literal hyphens,
local/global/globaldefs restoration, late assignments, line/baseline glue,
nested box copies, dependencies, snapshots and overflow diagnostics.
- Native CLI and real pdfTeX both export **six pages, 14 words**, with identical
word order on every page. Maximum word-box errors are xMin 0, xMax 0.009771,
yMin 0.000278 and yMax 0.000078bp, below the unchanged 0.02bp threshold.
The checker now verifies page-local text ownership and requires an explicit
expected page count (default one). It cannot accept a different page split
merely because the flattened word stream is equal.
- Complete frozen workspace: **1176 passed / 0 failed**, including 14 CLI tests
(native_execution 11 and native_job_io 3). Release, fmt/diff, the existing
math/paragraph/box PDF gates and math D vector/ink regression pass.
Prior 205 box, 119 paragraph, 117 math geometry/list, 88 math break, 90 token,
101 quantity, 12 filesystem and shipout-I/O comparisons remain covered.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_interline -- --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/interline.tex --expected-pages 6 \
--output-dir /tmp/texrra-native-interline/interline \
--json /tmp/texrra-native-interline/interline/pdf-oracle.json
python3 scripts/probe-native-format.py --binary target/release/texrra \
--texmf /usr/share/texlive/texmf-dist \
--json /tmp/texrra-native-interline/format-probe-final.json
~~~
Evidence: /tmp/texrra-native-interline/ contains the six-page native/reference
PDFs, raster, three previous PDF audits, format-probe-final.json and arXiv
math-regression.json. Final logs: /tmp/texrra-native-interline-workspace.log,
/tmp/texrra-native-interline-release.log and /tmp/texrra-native-interline-core.log.
The pinned entry SHA is unchanged; the full input/font closure remains uncertified.
## Actual format boundary and next work
The unmodified LaTeX2e 2025-11-01 entry now advances through clubpenalty and
widowpenalty to **latex.ltx:502:1, missing displaywidowpenalty**. Its actual
auxiliary timestamp write/read and directory checks still execute.
format_boot_passed remains false. No guard, format source or version marker
was changed. Broken/interline parameters have real consumers even though this
format initialization hits the display-widow blocker before assigning them.
Next implement native display mode transitions, paragraph completion with the
actual display-widow penalty, pre/post-display penalties and skips, and the
corresponding page/depth/baseline behavior. Do not alias displaywidowpenalty to
ordinary widowpenalty or register it merely to pass initialization. Native
display and the remaining math fields/primitives, arbitrary fonts/NFSS, actual
output/shipout, full format startup and realtime checkpoints remain open.
HTTP/project endpoints still use the transitional frontend; the accepted math D
gate is separate from native display execution and provides no fallback path.