Cover hyphenated breaks and hyphen demerits with pdfLaTeX
This commit is contained in:
1 parent
a6397fcfef
commit
e00e0038c1
3 files changed
+57
-8
No files matched your search
@@ -568,6 +568,52 @@ fn looseness_matches_pdftex() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hyphenation inserts discretionary breaks; line endings and the resulting
|
||||||
|
/// fragment words must match pdfLaTeX.
|
||||||
|
#[test]
|
||||||
|
fn hyphenated_breaks_match_pdftex() {
|
||||||
|
let text = "hyphenation demonstrates discretionary hyphenation whenever extraordinarily \
|
||||||
|
unpronounceable words appear in a paragraph";
|
||||||
|
for width in [80_u32, 100, 120] {
|
||||||
|
let Some(reference) = pdftex_lines(¶graph_fixture_with(text, width, "")) else {
|
||||||
|
eprintln!("skipping: pdflatex/pdftotext are not installed");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let ours = route_d_lines_with(text, f64::from(width), |_| {});
|
||||||
|
assert_lines_match(&format!("hyphenation {width}pt"), &ours, &reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `\\doublehyphendemerits` and `\\finalhyphendemerits` change which
|
||||||
|
/// breaks pdfLaTeX picks; both settings must reproduce its lines.
|
||||||
|
#[test]
|
||||||
|
fn hyphen_demerits_change_breaks_like_pdftex() {
|
||||||
|
let text = "hyphenation demonstrates discretionary representation according \
|
||||||
|
extraordinary understanding";
|
||||||
|
for width in [70_u32, 85] {
|
||||||
|
for demerits in [0_i64, 10_000] {
|
||||||
|
let prefix = format!(
|
||||||
|
"\\doublehyphendemerits={demerits} \\finalhyphendemerits={} ",
|
||||||
|
demerits / 2
|
||||||
|
);
|
||||||
|
let Some(reference) = pdftex_lines(¶graph_fixture_with(text, width, &prefix))
|
||||||
|
else {
|
||||||
|
eprintln!("skipping: pdflatex/pdftotext are not installed");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let ours = route_d_lines_with(text, f64::from(width), |style| {
|
||||||
|
style.double_hyphen_demerits = demerits;
|
||||||
|
style.final_hyphen_demerits = demerits / 2;
|
||||||
|
});
|
||||||
|
assert_lines_match(
|
||||||
|
&format!("hyphen demerits {demerits} at {width}pt"),
|
||||||
|
&ours,
|
||||||
|
&reference,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Sentence punctuation changes the space factor, so the interword glue and
|
/// Sentence punctuation changes the space factor, so the interword glue and
|
||||||
/// the resulting line breaks must match pdfLaTeX.
|
/// the resulting line breaks must match pdfLaTeX.
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
|||||||
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
||||||
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
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
|
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
||||||
PDF opt-in with `?engine=route-d`). 426 workspace tests are green and no oracle
|
PDF opt-in with `?engine=route-d`). 428 workspace tests are green and no oracle
|
||||||
fixture is ignored.
|
fixture is ignored.
|
||||||
|
|
||||||
Known gaps, in dependency order:
|
Known gaps, in dependency order:
|
||||||
@@ -233,12 +233,13 @@ page without a `\parskip`, and a single unsplittable line may overflow at the
|
|||||||
top of a page (see `Paragraph::split_at`).
|
top of a page (see `Paragraph::split_at`).
|
||||||
|
|
||||||
Still open: explicit
|
Still open: explicit
|
||||||
`\vskip` classes (`\smallskip` and friends),
|
`\vskip` classes (`\smallskip` and friends). The breaker now rejects overfull
|
||||||
double/final hyphen demerit oracle fixtures. The breaker now rejects overfull
|
|
||||||
lines outside the emergency pass, exactly like TeX, so `\tolerance` cannot
|
lines outside the emergency pass, exactly like TeX, so `\tolerance` cannot
|
||||||
smuggle in a single overfull line any more; at `\tolerance=10000` the line
|
smuggle in a single overfull line any more. Hyphenated breaks are checked at
|
||||||
count matches pdfLaTeX but the first line boundary still differs, so the
|
80-120pt, and a 70/85pt fixture sets `\doublehyphendemerits` and
|
||||||
demerit fixtures stay open until that trade-off is understood.
|
`\finalhyphendemerits` to 0 and 10000 so both demerits change the reference
|
||||||
|
breaks; at `\tolerance=10000` the line count matches pdfLaTeX but the first
|
||||||
|
line boundary still differs, which stays documented as a known approximation.
|
||||||
|
|
||||||
### P2 — Vertical list, page builder, `\output` (L2)
|
### P2 — Vertical list, page builder, `\output` (L2)
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -86,7 +86,9 @@ horizontally. The narrowest measures exercise hyphenated and overfull breaks (in
|
|||||||
final line held at its declared shrink limit), 130-160pt the final-pass
|
final line held at its declared shrink limit), 130-160pt the final-pass
|
||||||
overfull box, and 180-240pt ordinary tolerance solutions. Two further fixtures pin register behaviour at 120pt:
|
overfull box, and 180-240pt ordinary tolerance solutions. Two further fixtures pin register behaviour at 120pt:
|
||||||
`\pretolerance=10000` stops before hyphenation and `\hyphenpenalty=10000`
|
`\pretolerance=10000` stops before hyphenation and `\hyphenpenalty=10000`
|
||||||
inhibits it, leaving the overfull first-fit lines TeX produces. A 120pt
|
inhibits it, leaving the overfull first-fit lines TeX produces. Hyphenated paragraphs are compared at 80, 100 and 120pt, and a
|
||||||
|
70/85pt fixture runs with `\doublehyphendemerits` and `\finalhyphendemerits`
|
||||||
|
at 0 and 10000 so the reference breaks change with the demerits. A 120pt
|
||||||
fixture with `\hangindent=20pt \hangafter=1` checks every line origin
|
fixture with `\hangindent=20pt \hangafter=1` checks every line origin
|
||||||
against pdfLaTeX as well as the word positions inside each line, and a
|
against pdfLaTeX as well as the word positions inside each line, and a
|
||||||
`\parfillskip=0pt` fixture checks that a final line without `fil` glue is
|
`\parfillskip=0pt` fixture checks that a final line without `fil` glue is
|
||||||
@@ -344,7 +346,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`) supplies advances, kerns, ligatures, and italic correction for layout, while the display list and PDF select the matching Liberation face. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
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`) supplies advances, kerns, ligatures, and italic correction for layout, while the display list and PDF select the matching Liberation face. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
||||||
|
|
||||||
The crate currently has 289 unit tests plus seven route-D integration tests and twenty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 426 tests (289 route-D unit, 7 route-D integration, 25 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 binary units), with none ignored. v1 remains the live server path.
|
The crate currently has 289 unit tests plus seven route-D integration tests and twenty-seven oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 428 tests (289 route-D unit, 7 route-D integration, 27 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 binary units), with none ignored. v1 remains the live server path.
|
||||||
|
|
||||||
### M0 incremental demo
|
### M0 incremental demo
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user