Render XeTeX OpenType math accents and stretch constructions

This commit is contained in:
gloamxun committed 2026-11-21 15:14:48 +08:00
1 parent 01b3931ae0
commit 821631778e
16 files changed
+825 -144

No files matched your search

@@ -126,6 +126,25 @@ impl Converter<'_> {
.as_ref()
.map(|f| self.owned_field(f, style.sub(), &n.source.sub))
.transpose()?;
let script_bounds = if let MathField::Char(c) | MathField::TextChar(c) = n.nucleus {
let font = self.state.fonts.font(self.family_font(c.family, style)?)?;
if let Some(face) = font.opentype()
&& let Some(math) = crate::opentype::MathConstants::read(face)?
{
Some(geometry::ScriptBounds {
subscript_top_max: math.measure(math.values.subscript_top_max()),
superscript_bottom_min: math.measure(math.values.superscript_bottom_min()),
paired_gap: math.measure(math.values.sub_superscript_gap_min()),
paired_superscript_bottom: math.measure(
math.values.superscript_bottom_max_with_subscript(),
),
})
} else {
None
}
} else {
None
};
let (_, placement) = geometry::place_scripts_with_layout(
body,
upper.as_ref().map(NativeBox::geometry).transpose()?,
@@ -136,6 +155,7 @@ impl Converter<'_> {
self.params(style.sup())?,
style,
i64::from(self.state.parameter(Parameter::Scriptspace).width()),
script_bounds,
);
let space = i64::from(self.state.parameter(Parameter::Scriptspace).width());
let scripts = match (upper, lower) {