Execute Unicode math codes and measured OpenType math characters

This commit is contained in:
gloamxun committed 2026-11-21 11:47:56 +08:00
1 parent ce8a780031
commit d17680fcd8
24 files changed
+687 -123

No files matched your search

@@ -117,20 +117,14 @@ impl Executor {
Meaning::Primitive(
p @ (Primitive::Textfont | Primitive::Scriptfont | Primitive::Scriptscriptfont),
) => {
let family = self.integer(files)?;
if !(0..16).contains(&family) {
return self.fail("native math family must be in 0..15");
}
let family = self.scan_math_family(files)?;
let size = match p {
Primitive::Textfont => 0,
Primitive::Scriptfont => 1,
_ => 2,
};
self.reads.insert(Dependency::MathFamily {
size,
family: family as u8,
});
self.state.math_font(size, family as u8)
self.reads.insert(Dependency::MathFamily { size, family });
self.state.math_font(size, family)
}
_ => return self.fail("expected native font identifier"),
};
@@ -140,10 +134,11 @@ impl Executor {
pub(super) fn missing_glyph(
&mut self,
font: FontId,
slot: u8,
slot: impl Into<u32>,
span: Span,
files: &mut impl SourceProvider,
) -> Result<(), Error> {
let slot = slot.into();
let tracing = self.read_parameter(Parameter::Tracinglostchars).width();
let online = self.read_parameter(Parameter::Tracingonline).width();
let destination = if tracing <= 0 {
@@ -156,14 +151,16 @@ impl Executor {
// TeX print_ASCII renders nonprinting bytes in ^^ notation. This is
// the requested slot, not a Unicode-to-font substitution.
self.reads.insert(Dependency::NewLineChar);
let printed = if u8::try_from(self.state.newlinechar).ok() == Some(slot) {
let printed = if u32::try_from(self.state.newlinechar).ok() == Some(slot) {
"\n".into()
} else {
match slot {
0..=31 => format!("^^{}", char::from(slot + 64)),
0..=31 => format!("^^{}", char::from(slot as u8 + 64)),
127 => "^^?".into(),
128..=255 => format!("^^{slot:02x}"),
_ => char::from(slot).to_string(),
_ => char::from_u32(slot)
.map(|c| c.to_string())
.unwrap_or_else(|| format!("U+{slot:04X}")),
}
};
let newline = u8::try_from(self.state.newlinechar).ok().map(char::from);