Split colour, link and sized runs at any base size

inline_math_segments returned None for every paragraph whose base size was not
10pt, so a 12pt or \Large paragraph kept \textcolor/\href/\textsuperscript
delimiters as literal text. Only inline math actually depends on the 10pt
metric baseline: build the segments at any size and fall back to literal
delimiters only when a math segment is present and the size differs.

The existing sized-href test moves from "href is stripped but not linked" to
"the sized run keeps its link", and a new 12pt test covers a red run, a link
and a superscript in one paragraph with no warnings.
This commit is contained in:
gloamxun committed 2026-10-26 23:37:14 +08:00
1 parent 15b5437987
commit 56faec6046
3 files changed
+39 -10

No files matched your search

+4 -3
View File
@@ -370,7 +370,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph.
The crate currently has 434 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 979 tests (434 route-D unit, 357 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path.
The crate currently has 434 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 980 tests (434 route-D unit, 358 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path.
### M0 incremental demo
@@ -539,5 +539,6 @@ honest open items against the "feature-complete LaTeX compiler" objective are:
as Type1 with per-glyph Liberation fallback; arbitrary NFSS families,
font subsetting and broad Unicode coverage (including more than the current
Greek fallback) remain open.
- **Inline runs**: colour/link/size segments are only split for 10pt
paragraphs; larger base sizes keep the delimiters literal.
- **Inline runs**: colour/link/sized runs split at any base size; inline math
still falls back to literal delimiters when the paragraph's base size is not
10pt, because math metrics are measured at 10pt.