diff --git a/crates/texrra-tex-core/assets/ptmb8t.tfm b/crates/texrra-tex-core/assets/ptmb8t.tfm new file mode 100644 index 0000000..4fbc033 Binary files /dev/null and b/crates/texrra-tex-core/assets/ptmb8t.tfm differ diff --git a/crates/texrra-tex-core/assets/ptmbi8t.tfm b/crates/texrra-tex-core/assets/ptmbi8t.tfm new file mode 100644 index 0000000..a8f0528 Binary files /dev/null and b/crates/texrra-tex-core/assets/ptmbi8t.tfm differ diff --git a/crates/texrra-tex-core/assets/ptmri8t.tfm b/crates/texrra-tex-core/assets/ptmri8t.tfm new file mode 100644 index 0000000..4ff155b Binary files /dev/null and b/crates/texrra-tex-core/assets/ptmri8t.tfm differ diff --git a/crates/texrra-tex-core/src/cmr10.rs b/crates/texrra-tex-core/src/cmr10.rs index 151bf1a..d8fb063 100644 --- a/crates/texrra-tex-core/src/cmr10.rs +++ b/crates/texrra-tex-core/src/cmr10.rs @@ -35,6 +35,12 @@ pub enum Cmr10Metrics { Math, /// Times Roman text metrics (`ptmr8t.tfm`). TimesRoman, + /// Times bold text metrics (`ptmb8t.tfm`). + TimesBold, + /// Times italic text metrics (`ptmri8t.tfm`). + TimesItalic, + /// Times bold italic text metrics (`ptmbi8t.tfm`). + TimesBoldItalic, } static CMR10_TFM: &[u8] = include_bytes!("../assets/cmr10.tfm"); @@ -55,6 +61,9 @@ static CMSY10_TFM: &[u8] = include_bytes!("../assets/cmsy10.tfm"); static MSBM10_TFM: &[u8] = include_bytes!("../assets/msbm10.tfm"); static EUFM10_TFM: &[u8] = include_bytes!("../assets/eufm10.tfm"); static PTMR8T_TFM: &[u8] = include_bytes!("../assets/ptmr8t.tfm"); +static PTMB8T_TFM: &[u8] = include_bytes!("../assets/ptmb8t.tfm"); +static PTMRI8T_TFM: &[u8] = include_bytes!("../assets/ptmri8t.tfm"); +static PTMBI8T_TFM: &[u8] = include_bytes!("../assets/ptmbi8t.tfm"); static CMR10_METRICS: OnceLock = OnceLock::new(); static CMBX10_METRICS: OnceLock = OnceLock::new(); @@ -74,6 +83,9 @@ static CMSY10_METRICS: OnceLock = OnceLock::new(); static MSBM10_METRICS: OnceLock = OnceLock::new(); static EUFM10_METRICS: OnceLock = OnceLock::new(); static PTMR8T_METRICS: OnceLock = OnceLock::new(); +static PTMB8T_METRICS: OnceLock = OnceLock::new(); +static PTMRI8T_METRICS: OnceLock = OnceLock::new(); +static PTMBI8T_METRICS: OnceLock = OnceLock::new(); fn parse(bytes: &[u8]) -> TfmMetrics { TfmMetrics::parse(bytes).expect("embedded TFM must be valid") @@ -167,6 +179,18 @@ fn parse_times_roman() -> TfmMetrics { parse(PTMR8T_TFM) } +fn parse_times_bold() -> TfmMetrics { + parse(PTMB8T_TFM) +} + +fn parse_times_italic() -> TfmMetrics { + parse(PTMRI8T_TFM) +} + +fn parse_times_bold_italic() -> TfmMetrics { + parse(PTMBI8T_TFM) +} + fn math_fraktur_metrics() -> &'static TfmMetrics { EUFM10_METRICS.get_or_init(parse_fraktur) } @@ -190,6 +214,9 @@ fn metrics_for(font: Cmr10Metrics) -> &'static TfmMetrics { Cmr10Metrics::MathBlackboard => MSBM10_METRICS.get_or_init(parse_blackboard), Cmr10Metrics::MathFraktur => EUFM10_METRICS.get_or_init(parse_fraktur), Cmr10Metrics::TimesRoman => PTMR8T_METRICS.get_or_init(parse_times_roman), + Cmr10Metrics::TimesBold => PTMB8T_METRICS.get_or_init(parse_times_bold), + Cmr10Metrics::TimesItalic => PTMRI8T_METRICS.get_or_init(parse_times_italic), + Cmr10Metrics::TimesBoldItalic => PTMBI8T_METRICS.get_or_init(parse_times_bold_italic), } } @@ -214,6 +241,9 @@ impl Cmr10Metrics { ParagraphFont::BoldSlanted => Self::BoldSlanted, ParagraphFont::MonoItalic => Self::MonoItalic, ParagraphFont::TimesRoman => Self::TimesRoman, + ParagraphFont::TimesBold => Self::TimesBold, + ParagraphFont::TimesItalic => Self::TimesItalic, + ParagraphFont::TimesBoldItalic => Self::TimesBoldItalic, } } @@ -502,6 +532,19 @@ mod tests { assert!(font.depth('g') > 0); } + #[test] + fn times_bold_and_italic_tfms_differ_from_roman() { + let roman = Cmr10Metrics::TimesRoman; + let differs = |face: Cmr10Metrics| { + ['A', 'm', 'W', 'f'] + .iter() + .any(|character| face.width(*character) != roman.width(*character)) + }; + assert!(differs(Cmr10Metrics::TimesBold)); + assert!(differs(Cmr10Metrics::TimesItalic)); + assert!(differs(Cmr10Metrics::TimesBoldItalic)); + } + #[test] fn times_roman_tfm_differs_from_cmr() { let roman = Cmr10Metrics::Roman; diff --git a/crates/texrra-tex-core/src/paragraph.rs b/crates/texrra-tex-core/src/paragraph.rs index 6b8e8a6..e68ec62 100755 --- a/crates/texrra-tex-core/src/paragraph.rs +++ b/crates/texrra-tex-core/src/paragraph.rs @@ -370,6 +370,12 @@ pub enum ParagraphFont { MonoItalic, /// Times Roman text selected by `\rmdefault{ptm}` (`ptmr8t`). TimesRoman, + /// Times bold text (`ptmb8t`). + TimesBold, + /// Times italic text (`ptmri8t`). + TimesItalic, + /// Times bold italic text (`ptmbi8t`). + TimesBoldItalic, } impl ParagraphFont { @@ -388,7 +394,10 @@ impl ParagraphFont { Self::Slanted => Self::Italic, Self::BoldSlanted => Self::BoldItalic, Self::MonoItalic => Self::Mono, - Self::TimesRoman => Self::Italic, + Self::TimesRoman => Self::TimesItalic, + Self::TimesItalic => Self::TimesRoman, + Self::TimesBold => Self::TimesBoldItalic, + Self::TimesBoldItalic => Self::TimesBold, } } @@ -402,7 +411,10 @@ impl ParagraphFont { Self::SmallCaps => Self::Bold, Self::Slanted | Self::BoldSlanted => Self::BoldSlanted, Self::MonoItalic => Self::MonoItalic, - Self::TimesRoman => Self::Bold, + Self::TimesRoman => Self::TimesBold, + Self::TimesItalic => Self::TimesBoldItalic, + Self::TimesBold => Self::TimesBold, + Self::TimesBoldItalic => Self::TimesBoldItalic, } } @@ -418,6 +430,9 @@ impl ParagraphFont { Self::Slanted | Self::BoldSlanted => Self::Slanted, Self::MonoItalic => Self::MonoItalic, Self::TimesRoman => Self::TimesRoman, + Self::TimesBold => Self::TimesRoman, + Self::TimesItalic => Self::TimesItalic, + Self::TimesBoldItalic => Self::TimesItalic, } } @@ -434,7 +449,10 @@ impl ParagraphFont { Self::SmallCaps => Self::Italic, Self::Slanted => Self::Italic, Self::BoldSlanted => Self::BoldItalic, - Self::TimesRoman => Self::Italic, + Self::TimesRoman => Self::TimesItalic, + Self::TimesItalic => Self::TimesItalic, + Self::TimesBold => Self::TimesBoldItalic, + Self::TimesBoldItalic => Self::TimesBoldItalic, } } @@ -450,7 +468,10 @@ impl ParagraphFont { Self::Sans | Self::SansItalic => Self::SansItalic, Self::SansBold => Self::SansBold, Self::SmallCaps => Self::Slanted, - Self::TimesRoman => Self::Slanted, + Self::TimesRoman => Self::TimesItalic, + Self::TimesItalic => Self::TimesItalic, + Self::TimesBold => Self::TimesBoldItalic, + Self::TimesBoldItalic => Self::TimesBoldItalic, } } @@ -466,6 +487,9 @@ impl ParagraphFont { Self::Slanted | Self::BoldSlanted => Self::Roman, Self::MonoItalic => Self::Mono, Self::TimesRoman => Self::TimesRoman, + Self::TimesItalic => Self::TimesRoman, + Self::TimesBold => Self::TimesBold, + Self::TimesBoldItalic => Self::TimesBold, } } @@ -492,6 +516,9 @@ impl ParagraphFont { Self::BoldSlanted => Self::Bold, Self::MonoItalic => Self::Mono, Self::TimesRoman => Self::TimesRoman, + Self::TimesItalic => Self::TimesRoman, + Self::TimesBold => Self::TimesBold, + Self::TimesBoldItalic => Self::TimesBold, } } diff --git a/crates/texrra-tex-core/src/render.rs b/crates/texrra-tex-core/src/render.rs index b971d7f..7eeda72 100755 --- a/crates/texrra-tex-core/src/render.rs +++ b/crates/texrra-tex-core/src/render.rs @@ -479,6 +479,9 @@ fn paragraph_face(font: ParagraphFont) -> FontFace { ParagraphFont::BoldSlanted => FontFace::BoldSlanted, ParagraphFont::MonoItalic => FontFace::MonoItalic, ParagraphFont::TimesRoman => FontFace::Roman, + ParagraphFont::TimesBold => FontFace::Bold, + ParagraphFont::TimesItalic => FontFace::Italic, + ParagraphFont::TimesBoldItalic => FontFace::BoldItalic, } } diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index c3f4e9a..92628b8 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -51,7 +51,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and PDF opt-in with `?engine=route-d`; flat `/preview` and project previews now -prefer route-D with a v1 fallback). 1075 workspace tests are green and no oracle +prefer route-D with a v1 fallback). 1076 workspace tests are green and no oracle fixture is ignored. Preview JSON also carries a `warnings` array naming environments route-D cannot lay out and control words that survived layout, so unsupported source is reported instead of being silently typeset. diff --git a/docs/ROUTE_D_STATUS.md b/docs/ROUTE_D_STATUS.md index 6040b82..c86a2d9 100755 --- a/docs/ROUTE_D_STATUS.md +++ b/docs/ROUTE_D_STATUS.md @@ -16,11 +16,11 @@ cargo test --workspace --offline or run `./scripts/verify-route-d.sh`, which executes both. -The workspace currently passes **1075 tests**: +The workspace currently passes **1076 tests**: | Suite | Tests | | --- | --- | -| route-D unit (engine) | 446 | +| route-D unit (engine) | 447 | | engine binary unit | 434 | | server integration | 67 | | v1 integration | 71 | @@ -29,7 +29,7 @@ The workspace currently passes **1075 tests**: | engine/core unit | 4 + 1 | Latest full run (web trial increment): `./scripts/verify-route-d.sh` passes -with fmt clean and **1075 tests** green. +with fmt clean and **1076 tests** green. Latest live check (2026-10-27): the debug server served `examples/hello.tex` from `target/debug/texrra serve`; `POST /preview` answered 200 with diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 36c2b71..644e79f 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -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 446 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1075 tests (446 core unit, 434 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 67 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. +The crate currently has 447 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1076 tests (447 core unit, 434 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 67 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; flat and project responses carry `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. ### M0 incremental demo @@ -524,7 +524,7 @@ deliberately open rather than approximated: ## Limits and remaining gaps -The suite currently stands at 1075 passing tests, with the workspace clean. +The suite currently stands at 1076 passing tests, with the workspace clean. Route-D serves both flat `/preview` and project preview/PDF requests by default (automatic v1 fallback; `?engine=v1` or `TEXRRA_ENGINE=v1` opts out). The objective's areas are implemented to the limits below; complex-script shaping is diff --git a/docs/TEX_FIDELITY_ROADMAP.md b/docs/TEX_FIDELITY_ROADMAP.md index 060019e..b7eefc6 100644 --- a/docs/TEX_FIDELITY_ROADMAP.md +++ b/docs/TEX_FIDELITY_ROADMAP.md @@ -39,8 +39,8 @@ execution is not a goal. horizontal/vertical offsets, so a `geometry` document gets its centred 6.5in text block and page-2/page-3 headers instead of content at x=0. - Still visibly different from TeX: - - body face uses Times metrics (`ptmr8t`) with Liberation Serif TrueType; - bold/italic Times faces and CMR-metric headings remain; + - body face uses Times Roman/bold/italic metrics (`ptmr8t`, `ptmb8t`, + `ptmri8t`, `ptmbi8t`) with Liberation Serif TrueType; - the arXiv class's top/bottom rules, "A Preprint" undertitle and uppercase Times title are drawn, and two author groups are laid out side by side as a centred two-column halign. ORCID icons are still missing; @@ -68,6 +68,8 @@ execution is not a goal. - Incremental bottlenecks: - release-mode measurements after the paragraph-unit cache: article-basic **47 ms**, arXiv late edit **p50 47.6 ms / p95 53.3 ms** (one page changed), + Times arXiv previews measured 12.5–17.5 ms warm and 191 ms cold in + this round; the Times TFM parse is lazy and cached. a 10-page simple document **p50 13 ms / p95 14.7 ms**; the measured 3-page and 10-page cases now meet the <100 ms target, while the cold first build is still 150–370 ms and a heading/front-matter edit still diff --git a/docs/WEB_ROUTE_D_EXPERIMENT.md b/docs/WEB_ROUTE_D_EXPERIMENT.md index 0b027d3..7877f0c 100644 --- a/docs/WEB_ROUTE_D_EXPERIMENT.md +++ b/docs/WEB_ROUTE_D_EXPERIMENT.md @@ -46,7 +46,7 @@ now means route-D. | Area | Route-D | Evidence / impact | | --- | --- | --- | -| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1075-test suite | +| Article/report basics: title, sections, lists, TOC, page numbers | Supported | corpus and 1076-test suite | | Inline/display math, equations, tags, cleveref | Supported | math tests, oracle fixtures | | Floats, captions, tables, booktabs | Supported | table/math tests, corpus | | PNG/JPEG/BMP `\includegraphics` | Supported | project image tests; PDF XObjects use pixel dimensions and the SVG preview embeds a PNG data URI | @@ -139,7 +139,7 @@ PDF was rendered page-by-page next to the route-D output. | Page element | TeX Live reference | Route-D output | | --- | --- | --- | | Page count / paper | 3 pages, letter | 3 pages, letter | -| Typeface | Times (`ptm`, arxiv.sty) | Times body metrics (`ptmr8t`) with Liberation Serif TrueType; headings still CMR metrics | +| Typeface | Times (`ptm`, arxiv.sty) | Times Roman/bold/italic metrics (`ptmr8t`, `ptmb8t`, `ptmri8t`, `ptmbi8t`) with Liberation Serif TrueType | | Text block | 1in left/right margins, 6.5in measure | 1in margins and 6.5in measure after the page-origin fix; body face still differs | | Running header | `arxiv Template` / `A PREPRINT` | `arXiv Template` / `A Preprint` on pages 2–3; small-caps styling differs | | Title | `A TEMPLATE FOR THE arxiv STYLE`, small caps, rules above/below | uppercase Times with rules above/below | diff --git a/src/route_d.rs b/src/route_d.rs index b3e5061..4da8697 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -9817,6 +9817,9 @@ fn nfss_font_with_size( ParagraphFont::BoldSlanted => (Family::Roman, true, false), ParagraphFont::MonoItalic => (Family::Mono, false, true), ParagraphFont::TimesRoman => (Family::Roman, false, false), + ParagraphFont::TimesBold => (Family::Roman, true, false), + ParagraphFont::TimesItalic => (Family::Roman, false, true), + ParagraphFont::TimesBoldItalic => (Family::Roman, true, true), }; let mut small_caps = base == ParagraphFont::SmallCaps; let mut slanted = matches!(base, ParagraphFont::Slanted | ParagraphFont::BoldSlanted); @@ -14118,10 +14121,14 @@ fn build_document_with_labels( xspace_skip: geometry.xspace_skip, }; let plain = strip_hrefs(&text).replace('~', " "); - let face = if geometry.roman_family.as_deref() == Some("ptm") - && paragraph.font == ParagraphFont::Roman - { - ParagraphFont::TimesRoman + let face = if geometry.roman_family.as_deref() == Some("ptm") { + match paragraph.font { + ParagraphFont::Roman => ParagraphFont::TimesRoman, + ParagraphFont::Bold => ParagraphFont::TimesBold, + ParagraphFont::Italic => ParagraphFont::TimesItalic, + ParagraphFont::BoldItalic => ParagraphFont::TimesBoldItalic, + other => other, + } } else { paragraph.font };