Commit Graph
399 Commits
Author SHA1 Message Date
gloamxun e9bbd4bd87 Use Times metrics for ptm documents
Add a merged ptmr8t TFM asset, a TimesRoman paragraph face and Cmr10Metrics
entry, map a ptm Roman paragraph to it, and select the Liberation Serif
TrueType PDF backend for those projects. The title is uppercased rather than
small-capped so its widths use Times metrics.

The arXiv PDF now embeds Liberation Serif for body text; title/author/abstract
land at y=88/173/277pt with three pages and all references. Headings and bold/
italic Times faces still use CMR metrics.

Test count is 1075.
2026-10-28 00:00:34 +08:00
gloamxun 2ef5e29329 Embed raster images in the SVG preview
The SVG preview painted every DisplayItem::Image as a grey rectangle. Encode
the raw RGB image as a PNG (zlib via flate2, CRC32, base64) and emit an SVG
<image> data URI; keep the grey fallback for images above four megapixels.

The article preview now contains the real 480x240 plot and the framed rule
figure is visible while editing. Test count stays 1074.
2026-10-27 23:50:48 +08:00
gloamxun 576626fe04 Centre table floats without losing rules or columns
The rule rectangle used width-margin for its right edge, so a centred table
shrank or lost its booktabs rules. Derive the right edge from the last column
offset instead, then centre a table float by shifting its margin. All three
columns and the rules now stay inside the measure.

Test count stays 1074.
2026-10-27 23:42:15 +08:00
gloamxun aa2f3cb0af Centre raster images inside floats
Add an x offset to VerticalItem::Image and use it when placing a decoded image
in a float, so a 0.4\textwidth plot is centred while its caption remains
centred across the float. Other image uses keep x=0.

Test count stays 1074.
2026-10-27 23:37:54 +08:00
gloamxun d00402a745 Use pixel dimensions for PDF image XObjects
The display-list conversion stored the layout width/height (scaled points)
as PdfImage.width/height, so an image XObject claimed 12 million pixels and
pdfimages reported bad image parameters; the image never appeared. Keep the
layout rectangle in DisplayItem::Image but use the raster pixel dimensions for
the XObject.

Verified pdfimages now lists the 480x240 plot and the article PDF shows it.
Test count stays 1074.
2026-10-27 23:30:26 +08:00
gloamxun 16dd2e1f62 Count image height in float content
VerticalItem::Image was missing from Float::content_height, so image floats
reported zero content height and could overlap following text. Include the
image height and add a regression test.

Test count is 1074.
2026-10-27 23:21:52 +08:00
gloamxun b1e3e03f00 Fix the arXiv-template PDF output
The user-supplied template PDF exposed four concrete problems:

- title/headings were letter-spaced: plain text in a large paragraph took the
  SizedText segment path and was scaled twice; the fallback run now stays at
  the base size and is scaled once by the paragraph;
- the table lost its third column because unsupported math glyphs were sent
  through the PDF fallback font; table-cell math now has a readable ASCII
  fallback (Size (um), approx. 100, 10**6);
- fancyhdr's \cfoot{\thepage} was painted together with route-D's default page
  number; default numbering is skipped for a fancy pagestyle;
- .bib data was ignored; simple @article/@inproceedings entries are now parsed
  from project .bib files, inlined as thebibliography entries, and resolved by
  the existing citation pass, producing References and [1]-[3].

The regenerated 3-page PDF was checked for title/heading spacing, table text,
references and a single page number per page. A project regression test covers
the .bib path, and the table/heading fixes have unit tests.

Remaining visible limits in this template: the complex display equation, the
\fbox/rule figure body, vector/PDF images and the author block layout.
Test count moves to 1069 (444 core, 432 engine, 65 server).
2026-10-27 13:38:36 +08:00
gloamxun 263fa36fb5 Activate dormant tests and clear route-D warnings
Three test functions in texrra-tex-core (PDF metadata, Type1 outline embedding
and \noalign row glue) were missing their #[test] attribute and only produced
dead-code warnings. With the attributes added they pass and raise the core suite
from 439 to 442 tests. The unused `mut` on the PDF entry point geometry is gone
too, leaving no route-D/PDF/lib compiler warnings in `cargo check
--workspace --all-targets`.
2026-10-27 04:09:26 +08:00
gloamxun 4068366190 Support xrightarrow and xleftarrow
The amsmath extensible arrows were unknown, so their labels fell back to plain
text. The math parser now reads \xrightarrow/\xleftarrow, an optional [below]
label, and the above label, and builds nested Stack atoms around the arrow
symbol: above stacks upward, an optional below label stacks downward.

The math test compares the bare arrow with the labeled form (width/height grow)
and with the two-label form (total height plus depth grows).
2026-10-27 03:18:20 +08:00
gloamxun 8307fc8918 Map boldsymbol to the bold math alphabet
\boldsymbol and \bm were unknown math commands, so a bold symbol fell back to
the default layout. Both names now select the same bold alphabet as \mathbf;
symbol-heavy arguments still use the regular symbol metrics, which is the
existing alphabet approximation.

A math test compares \boldsymbol{x} with \mathbf{x} for equal width and height.
2026-10-27 03:15:16 +08:00
gloamxun 9da0f136a4 Show the current heading in headings-style headers
The headings page style only painted the page number. Document now records its
heading units (unit index and title) during layout, and a page_headings helper
carries the latest heading from page to page through the page sources. The
running-head pass uses that list in headings style: the numbered heading title
is uppercased at the left of the header and the page number stays right-aligned,
with the first page still plain.

The headings test gains a section and checks "1 INTRODUCTION" sits at the left
of the header baseline.
2026-10-27 02:44:14 +08:00
gloamxun 88a03ec1a1 Scale inline math proportionally
Inline math in a 12pt paragraph kept 10pt glyphs because paint_math advances
with 10pt metrics. Paint the math atom into a temporary display list at the
10pt baseline and scale that list as a unit (text sizes and positions, rule
widths/heights, line endpoints) to the paragraph size before translating it to
the baseline. The box no longer pins its size, so a scaled math glyph now
reports font-size 12.000 in a 12pt paragraph.

The twelve-point test now also asserts that an italic math glyph is rendered at
the paragraph size; the sized-paragraph test still expects a math box and no
literal dollars.
2026-10-27 01:36:59 +08:00
gloamxun b3fbbc8dda Render inline math in sized paragraphs
Inline math returned None whenever the paragraph base size was not 10pt, so a
12pt or \large paragraph printed its dollar delimiters literally. Keep the math
segment at every size: the box width still scales with the paragraph, while the
math glyphs are pinned to the 10pt metric baseline by setting the box's size
field, so paint positions and glyph sizes stay consistent (slightly smaller
than the surrounding text, which is documented).

The old sized-paragraph test now expects a math box and no literal dollars; a
new 12pt preview test checks italic math glyphs and no "$" with no warnings.
2026-10-27 01:34:07 +08:00
gloamxun 47dcdfec47 Print tokens literally with string
\string<token> was unsupported, so documenting a control sequence expanded it
instead of printing it. The expand loop now reads the following token and emits
its characters without expansion; backslash and braces are replaced by
private-use placeholders that the renderer maps back to the real characters, so
the printed text cannot be re-tokenised and expanded by a later pass.

A preview test defines \foo, prints \string\foo, \string{ and \string}, and
checks the literal "\foo and { and }." with no expansion of \foo and no
warnings.
2026-10-27 01:16:30 +08:00
gloamxun 81da180ab7 Lay out nested tables inside their cell
Nested tabulars were flattened to a text summary before the outer halign
parsed them, so the inner rows never existed as a table. Keep them instead:
strip_page_geometry replaces each nested block with a \texrranested{index}
token and stores the source on the geometry, and tabular_unit resolves the
token into a recursively built inner table attached to the cell. Cell text is
cleared, column widths and row height take the inner table's metrics, and page
splitting remaps nested row indices when it chunks rows.

Halign gains a nested list, refresh_measurements, nested-aware row_height and a
painting branch that translates the inner display list to the cell position at
the row's alignment. The old flattening pass stays as a dead-code fallback.

The nested-table test now checks one stored source, the placeholder token, one
attached 2x2 table in cell (0, 1), an empty outer cell and inner "a"/"d"
painted in the preview SVG.
2026-10-27 00:38:02 +08:00
gloamxun 4b28d65006 Render Greek math commands as their letters
\alpha through \omega, the uppercase Greek commands and the varepsilon /
vartheta / varrho / varsigma / varphi / varpi / varkappa variants were not in
the math command table, so a formula such as $\alpha+\beta$ painted "?" glyphs.

Map them to their Unicode code points. The math renderer already treats the
Greek ranges as math letters and sends them through the math-italic fallback,
so the formula now previews as α+β=γ with no warnings; the widths still use the
TFM fallback constant rather than per-letter cmmi metrics.

A core test pins the parsed symbols and a route-D test checks the previewed
characters.
2026-10-26 23:52:44 +08:00
gloamxun 5a1a04d029 Freeze savebox metrics and expand wd/ht/dp
\sbox/\savebox now measure their content at definition with the Roman metrics
at the class base size and store width/height/depth. \usebox carries that size
into the no-break segment, which scales the box back to its definition size
inside a differently sized paragraph, and \wd/\ht/\dp\boxname expand to the
frozen metrics before paragraph parsing.

\mbox/\hbox/\makebox keep following the surrounding size (their marker carries
size 0). A core test checks that a box frozen at 20pt is twice as wide as the
10pt one, and a route-D test checks the measured dimensions and a
\hspace{\wd\box} expansion. Image-only boxes still measure as empty text.

Three savebox tests strip the internal markers (now with their size prefix)
before comparing visible text.
2026-10-26 23:48:42 +08:00
gloamxun 95a6a1291a Keep mbox and savebox content on one line
Add InlineSegment::NoBreak: it shapes each word and replaces the interword
glue with fixed-width boxes, so the run has no breakpoints and behaves like
TeX's unbreakable hbox rather than reflowing at the use site.

Route-D wraps \usebox bodies and \mbox/\hbox/\makebox arguments in private-use
markers; the paragraph text builder splits on them and emits NoBreak runs,
leaving ordinary text and styling on the existing path. \underline keeps its
old inline behaviour.

A 60pt measure now keeps \mbox{alpha beta gamma} and a stored
\sbox{alpha beta gamma} on one line, covered by a core segment test and a
route-D test. Savebox dimensions are still measured at the use site instead of
being frozen at definition, and \wd/\ht/\dp accessors remain open.
2026-10-26 23:43:53 +08:00
gloamxun 2f9b18c95c Reserve display skips around math
TeX surrounds each display with \abovedisplayskip above and \belowdisplayskip
below, but route-D only reserved the paragraph's own spacing, so displays sat
directly against the surrounding text. Parse the four registers (including the
short forms), default to the article-class 10/11/12pt values, and add them to
the math unit and the unit that follows it.

The glue parser now also accepts the class-file spelling
(`\abovedisplayskip 7\p@ \@plus 2\p@ \@minus 5\p@`), register copies such as
`\belowdisplayskip \abovedisplayskip`, `\z@`/`\p@` dimensions and
space-separated assignments, which clears the display-skip warnings the arXiv
template produced.

A page oracle sets a 45pt above skip and pins the display moving to the second
page exactly as pdfLaTeX lays it out; unit tests cover the defaults, overrides
and the class-file spelling.
2026-10-26 22:49:41 +08:00
gloamxun 8ac2e828df Honour club and widow penalties on paragraph lines
Route-D expanded a paragraph into one node per line without TeX's
\clubpenalty/\widowpenalty, so a page break could orphan the first line or
widow the last. Insert the penalties between line nodes (150 by default, read
from the source registers) and make the page builder reject any penalty of
10000 or more as a breakpoint. Forced -10000 values now break exactly where
pdfLaTeX does; two page oracle fixtures compare per-page text, and unit tests
cover the node order and the forbidden breakpoint.
2026-10-26 22:14:01 +08:00
gloamxun 83f49db49e Sort oracle word boxes before grouping lines
pdftotext 26 does not always emit words in reading order: wide justified gaps and hyphenated lines interleave words from different baselines, so parse_bbox split one visual line into several. Sort by baseline and then x before grouping. It also reports each word box as the font extent, whose ascent varies with type size; compare display limits by the subscript/superscript baseline gap, which is anchor-free, instead of mixing 7pt box tops with the 10pt base.
2026-10-26 22:03:25 +08:00
gloamxun e09e413892 Break long paragraphs with prefix sums
The line-breaker rescanned items[start..end] for every break pair, so a 900-word paragraph took seconds and the 2,700-word edit fixture took about 30 s. Prefix sums over natural width, stretch, shrink, glue order, box count and the last penalty give each candidate its metrics in O(1); the search now costs O(breakpoints^2) and the same document lays out in about 0.3 s. Add a 900-word regression test and note the change in TEX_CORE.
2026-10-26 22:03:19 +08:00
gloamxun 7271e2ee12 End table rows with tabularnewline 2026-10-26 20:36:57 +08:00
gloamxun f147ccc8c5 Parse array column modifiers and their alignment 2026-10-26 20:31:33 +08:00
gloamxun 8ecbd5e720 Centre multirow cells over their rows 2026-10-26 20:31:03 +08:00
gloamxun aa072f58d8 Reserve outer tabcolsep margins around tables 2026-10-26 20:29:51 +08:00
gloamxun 0c8228eced Lay out ensuremath bodies as math 2026-10-26 04:14:38 +08:00
gloamxun 0340878909 Pad color boxes by fboxsep 2026-10-26 04:11:42 +08:00
gloamxun 8e274a252d Separate table columns by twice tabcolsep 2026-10-26 04:09:57 +08:00
gloamxun d89b71bfbc Measure table cells with Computer Modern metrics 2026-10-26 04:07:29 +08:00
gloamxun 994c360ec0 Draw fbox frames without a background 2026-10-26 03:51:28 +08:00
gloamxun 90cf2236ee Space booktabs rows with addlinespace 2026-10-26 03:43:29 +08:00
gloamxun 2018e5f8b8 Paint framed colorbox backgrounds 2026-10-26 03:08:37 +08:00
gloamxun d88e74cd29 Paint colorbox backgrounds 2026-10-26 03:05:07 +08:00
gloamxun c95cfa5967 Colour link annotation borders 2026-10-26 02:48:57 +08:00
gloamxun ea89bc1522 Colour href labels from hypersetup 2026-10-26 02:38:41 +08:00
gloamxun 1ab2a29bfa Fill the page background with pagecolor 2026-10-26 02:31:50 +08:00
gloamxun 028137a9ad Parse phantom bodies as braced groups 2026-10-26 01:41:27 +08:00
gloamxun 9ad404acee Paint textcolor runs in named colours 2026-10-26 01:41:00 +08:00
gloamxun 7ba66392ea Set operator names upright and declare new ones 2026-10-26 01:24:46 +08:00
gloamxun a4c4864d2b Nest PDF bookmarks by heading level 2026-10-26 01:20:41 +08:00
gloamxun 5f98c199a5 Write PDF bookmarks for section headings 2026-10-26 01:17:42 +08:00
gloamxun 863e7c1a81 Write PDF metadata from hypersetup 2026-10-26 01:15:02 +08:00
gloamxun 8686b9a35e Stack substack rows with TeX inter-row gaps 2026-10-26 01:12:00 +08:00
gloamxun ab5e857705 Build genfrac fractions with explicit delimiters 2026-10-26 01:03:31 +08:00
gloamxun d237e0cc9b Keep integral scripts beside the operator 2026-10-26 01:01:11 +08:00
gloamxun 569160f805 Check stacked limits against pdfLaTeX 2026-10-26 00:59:19 +08:00
gloamxun 52a74755f7 Check matrix and cases positions against pdfLaTeX 2026-10-26 00:53:40 +08:00
gloamxun e926bc9eb3 Honour explicit limits and nolimits on operators 2026-10-26 00:48:52 +08:00
gloamxun 29d363d47a Set multline rows flush to the margins 2026-10-26 00:46:22 +08:00