Add paragraph indentation and hfill

This commit is contained in:
gloamxun committed 2026-10-19 12:43:30 +08:00
1 parent bad477fbee
commit e44d4c8669
11 files changed
+362 -42

No files matched your search

+8 -21
View File
@@ -3,23 +3,10 @@
This file lists the concrete implementation plans for the foundational items that
are still missing. Each item names the files/functions to touch.
## 1. Paragraph indentation (`\parindent`)
Completed: paragraph indentation (`\parindent`) and `\hfill`/`\hfil` (see
`docs/STATUS.md`).
- Add `parindent: Scaled` to `DocumentModel` (with the 11pt article default 17pt)
and a `Parindent` frontend event.
- Feed `\setlength{\parindent}{...}` through an **engine-side named length
register** (the adapter already stores named lengths); when the register is
written, emit the event. Do not use a prelude `\ifx` conditional: it broke
preamble loading when tried.
- Apply indentation inside the paragraph breaker: the first line's available
width is `line_width - parindent` and its start x is `parindent`.
`boxworks_line_break` / `cached_paragraph_lines` currently take only a width;
extend the signature with a first-line indent and carry the per-line x offset
into `text_layout::LineBox`/`PositionedLine.x`.
- Suppress after headings, after `\maketitle`, and for `\noindent`; track a
`suppress_indent` flag in the parser.
## 2. Sans family (`\sffamily`)
## 1. Sans family (`\sffamily`)
- Load Liberation Sans in `latin_dir` alongside serif/mono (see
`font_inputs`/`register_box_font_family` in `src/rust_typeset/pdf.rs`).
@@ -30,7 +17,7 @@ are still missing. Each item names the files/functions to touch.
- `\sffamily`/`\textsf{...}` become declaration primitives like
`\ttfamily`.
## 3. Inline framed boxes / `\raisebox`
## 2. Inline framed boxes / `\raisebox`
- Add `y_offset: Mm` to `PositionedSpan` and `PositionedRule`; PDF/SVG painters
add it to the baseline.
@@ -41,7 +28,7 @@ are still missing. Each item names the files/functions to touch.
box rectangle when `frame` is set.
- `\raisebox{lift}{...}` reuses the same nested item with `raise = lift`.
## 4. Footnotes
## 3. Footnotes
- Parser: capture `\footnote{...}`/`\thanks{...}` into a per-paragraph list
with a number marker run (superscript approximation via smaller raised text
@@ -50,7 +37,7 @@ are still missing. Each item names the files/functions to touch.
text height and place footnotes with a separator rule at the bottom.
- Paint footnotes as normal positioned lines after the page's content.
## 5. Floats
## 4. Floats
- Classify figure/table blocks as floats with `[htbp]` placement hints.
- Planner: maintain pending floats and try top/bottom/page placements; keep
@@ -58,13 +45,13 @@ are still missing. Each item names the files/functions to touch.
- Renderer: place deferred floats at the saved slots; page keys must include
float placement decisions.
## 6. Page styles / headers-footers
## 5. Page styles / headers-footers
- `DocumentModel` fields for header/footer runs and `\pagestyle`/`\thispagestyle`.
- Paint headers/footers in the page margins in both PDF and SVG; page numbers
need a page index placeholder resolved at paint time.
## 7. Unified pagination
## 6. Unified pagination
- Extract the current duplicated planner (`build_page_break_plan`) and renderer
(`build_positioned_pages`) vertical logic into one page builder returning an
+3 -5
View File
@@ -17,7 +17,8 @@ the source changes; the SVG preview is refreshed per page.
- Fonts: Liberation Serif/Mono faces, bold/italic/monospace declarations with
group scoping, grouped text-style commands, uppercase small-caps approximation.
- Paragraphs: Knuth-Plass breaking, TeX hyphenation patterns, justification,
centering.
centering, first-line `\parindent` (17pt default, group-scoped, `\setlength`/
`\addtolength`/`\noindent` aware), and `\hfill`/`\hfil` infinite glue.
- Pages: A4/A5/B5/Letter/Legal/Executive, landscape, geometry margins and
text block, automatic pagination, `\newpage`/`\pagebreak`.
- Classes/packages: built-in classes, local `.cls`/`.sty`, paper options,
@@ -34,9 +35,6 @@ See `docs/ROADMAP.md` for concrete implementation plans.
## Known approximations / gaps
- Paragraphs: no `\parindent` indentation (a parse-side kern experiment did not
take effect and a `\setlength` conditional broke the preamble, so it was
reverted) and no `\hfill` (last-line infinite glue is not stretched).
- Fonts: no sans family (`\sffamily` is a no-op); small caps are uppercase-only.
- Boxes: `\fbox`/`\parbox` are block-level (an inline `\fbox` starts a block);
`\raisebox`, `\minipage`, and VBox material are missing.
@@ -52,7 +50,7 @@ See `docs/ROADMAP.md` for concrete implementation plans.
- `examples/hello.tex`, `examples/boxes.tex`, `examples/compat.tex` compile to
one A4 page each; the arXiv template project compiles to 3 Letter pages.
- `cargo fmt --check` passes; `cargo test --workspace` (12 tests) covers the three
- `cargo fmt --check` passes; `cargo test --workspace` (15 tests) covers the three
examples, the arXiv fixture, SVG/PDF output, project API, static frontend
assets, path traversal, the legacy `/texrra` endpoint, and page-hash cache
stability.