Match XeTeX math script kerning and fraction font selection

This commit is contained in:
gloamxun committed 2026-11-21 15:33:05 +08:00
1 parent 821631778e
commit a31de14eb2
9 files changed
+255 -12

No files matched your search

@@ -70,6 +70,7 @@ impl Converter<'_> {
style: MathStyle,
) -> Result<Vec<TextNode>, String> {
let params = self.params(style)?;
let start_font = self.current_math_font.get();
let limits = n.limits == OperatorLimits::AboveBelow
|| (n.limits == OperatorLimits::Display && style.display());
// TeX cleans the upper limit first for a sub-mlist nucleus, but fetches
@@ -88,6 +89,7 @@ impl Converter<'_> {
let id = self.family_font(c.family, style)?;
let mut source = n.source.nucleus.clone();
let font = self.state.fonts.font(id)?;
self.current_math_font.set(id);
let (mut b, italic) = if !self.has_math_char(id, c.slot)? {
self.missing.borrow_mut().push((id, c.slot));
(self.pack_field(Vec::new())?, 0)
@@ -146,6 +148,11 @@ impl Converter<'_> {
side.nucleus = MathField::Box(Box::new(body));
return self.script_noad(&side, style, false, italic);
}
let limits_font = if matches!(n.nucleus, MathField::Char(_)) {
self.current_math_font.get()
} else {
start_font
};
let mut upper = if let Some(upper) = early_upper {
upper
} else {
@@ -164,6 +171,7 @@ impl Converter<'_> {
.as_ref()
.map(|f| self.owned_field(f, style.sub(), &n.source.sub))
.transpose()?;
self.current_math_font.set(limits_font);
let width = body
.width
.max(upper.as_ref().map_or(0, |b| b.width))