Add Fraktur letters, infix fractions and middle delimiters

- bundle eufm10 (TFM + Type1), add the MathFraktur face and map \mathfrak
  onto it, including PDF embedding and width lookup;
- parse TeX's infix fractions (\over, \atop, \choose, \brace,
  \brack, \overwithdelims, \atopwithdelims): the rest of the current
  row becomes the denominator, ar records whether a rule is drawn, and the
  painter no longer emits parentheses (a \frac painter bug) and only draws
  the bar for \over forms;
- add MathAtom::Middle, size top-level middle delimiters with the enclosing
  \left/\right group through the CMEX size classes, and paint
  SizedDelimiter at its selected size instead of the base glyph;
- skip the parser's '\u{0}' math spaces before \big, \middle,
  \left and the withdelims delimiters, so \big ( parses like \big(.

560 workspace tests (381 route-D unit).
This commit is contained in:
texrra committed 2026-10-24 12:28:33 +08:00
1 parent cb40cc4634
commit 8c42f2de2f
10 files changed
+499 -72

No files matched your search

+106
View File
@@ -4235,6 +4235,29 @@ mod tests {
)));
}
#[test]
fn mathfrak_paints_with_the_eufm_face() {
use crate::render::{DisplayItem, FontFace};
let document = Document::new(
1_000_000,
vec![Unit::math(
1,
crate::math::parse_math("\\mathfrak{A}"),
&Cmr10Metrics::Math,
)],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
assert!(list.items.iter().any(|item| matches!(
item,
DisplayItem::Text {
text,
font: FontFace::MathFraktur,
..
} if text == "A"
)));
}
#[test]
fn edit_on_second_page_only_rebuilds_second_page() {
let mut document = document();
@@ -6328,6 +6351,48 @@ mod tests {
assert!(svg.contains("font-family=\"monospace\">face3"));
}
#[test]
fn big_delimiters_paint_at_their_selected_size() {
let atom = crate::math::parse_math("\\big(");
let document = Document::new(
400,
vec![Unit::math(1, atom, &crate::cmr10::Cmr10Metrics::new())],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
let size = list
.items
.iter()
.find_map(|item| match item {
DisplayItem::Text { text, size, .. } if text == "(" => Some(*size),
_ => None,
})
.expect("big paren should be painted");
assert!(size > 655_360, "expected a larger glyph, got {size}");
}
#[test]
fn middle_delimiters_paint_larger_than_the_base_glyph() {
let atom = crate::math::parse_math(
"\\left( \\frac{\\frac{a}{b}}{\\frac{c}{d}} \\middle\\{ c \\right)",
);
let document = Document::new(
400,
vec![Unit::math(1, atom, &crate::cmr10::Cmr10Metrics::new())],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
let size = list
.items
.iter()
.find_map(|item| match item {
DisplayItem::Text { text, size, .. } if text == "{" => Some(*size),
_ => None,
})
.expect("middle brace should be painted");
assert!(size > 655_360, "expected a larger glyph, got {size}");
}
#[test]
fn binomial_is_painted_with_parentheses() {
let document = Document::new(
@@ -6459,6 +6524,47 @@ mod tests {
assert!(svg.contains(">x</text>"));
}
#[test]
fn fractions_paint_a_rule_without_parentheses() {
let atom = crate::math::parse_math("\\frac{a}{b}");
let document = Document::new(
400,
vec![Unit::math(1, atom, &crate::cmr10::Cmr10Metrics::new())],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
assert!(
!list.items.iter().any(|item| matches!(
item,
DisplayItem::Text { text, .. } if text == "(" || text == ")"
)),
"fractions must not paint parentheses: {:?}",
list.items
);
assert!(
list.items
.iter()
.any(|item| matches!(item, DisplayItem::Rule { .. }))
);
}
#[test]
fn atop_paints_without_a_fraction_rule() {
let atom = crate::math::parse_math("a \\atop b");
let document = Document::new(
400,
vec![Unit::math(1, atom, &crate::cmr10::Cmr10Metrics::new())],
);
let engine = Engine::layout(&document);
let list = engine.pages()[0].display_list();
assert!(
!list
.items
.iter()
.any(|item| matches!(item, DisplayItem::Rule { .. }))
);
}
#[test]
fn big_operators_paint_with_the_cmex_face() {
let atom = crate::math::parse_math("\\sum_{i=1}^{n}");