Execute Unicode math codes and measured OpenType math characters
This commit is contained in:
1 parent
ce8a780031
commit
d17680fcd8
24 files changed
+687
-123
No files matched your search
@@ -18,6 +18,7 @@ mod input;
|
||||
mod list_tail;
|
||||
mod marks;
|
||||
mod math;
|
||||
mod math_codes;
|
||||
mod nesting;
|
||||
mod page;
|
||||
mod paragraphs;
|
||||
@@ -1224,6 +1225,7 @@ impl Executor {
|
||||
&& !matches!(
|
||||
meaning,
|
||||
Meaning::Character(_) | Meaning::CharGiven(_) | Meaning::MathCharGiven(_)
|
||||
| Meaning::UnicodeMathCharGiven(_)
|
||||
)
|
||||
&& let TokenKind::Command(CommandName::Active(c)) = input.token.kind
|
||||
{
|
||||
@@ -1917,6 +1919,9 @@ impl Executor {
|
||||
}
|
||||
Meaning::MathCharGiven(code as u16)
|
||||
}
|
||||
Umathchardef | Umathcharnumdef => Meaning::UnicodeMathCharGiven(
|
||||
self.scan_unicode_math_code(primitive == Umathchardef, files)?,
|
||||
),
|
||||
Countdef => Meaning::Count(self.register_index(files)?),
|
||||
Toksdef => Meaning::Toks(self.register_index(files)?),
|
||||
Dimendef | Skipdef | Muskipdef => {
|
||||
@@ -2008,10 +2013,14 @@ impl Executor {
|
||||
Ok(Key::Delcode(c))
|
||||
}
|
||||
Meaning::Primitive(Primitive::Mathcode) => {
|
||||
let c = self.integer(files)?;
|
||||
let c = u8::try_from(c)
|
||||
.map_err(|_| self.error("mathcode index must be in 0..255", self.current))?;
|
||||
Ok(Key::Mathcode(c))
|
||||
Ok(Key::Mathcode(self.scan_math_code_index(files)?))
|
||||
}
|
||||
Meaning::Primitive(Primitive::Umathcodenum) => {
|
||||
Ok(Key::Mathcodenum(self.scan_math_code_index(files)?))
|
||||
}
|
||||
Meaning::Primitive(Primitive::Umathcode) => {
|
||||
self.scan_math_code_index(files)?;
|
||||
self.fail(r"Can't use \Umathcode as a number (try \Umathcodenum)")
|
||||
}
|
||||
Meaning::Primitive(Primitive::Catcode) => {
|
||||
let number = self.integer(files)?;
|
||||
@@ -2042,10 +2051,12 @@ impl Executor {
|
||||
self.reads.insert(Dependency::DelCode(*c));
|
||||
self.state.delcode(*c)
|
||||
}
|
||||
Key::Mathcode(c) => {
|
||||
self.reads.insert(Dependency::MathCode(*c));
|
||||
self.state.mathcode(*c) as i32
|
||||
}
|
||||
Key::Mathcode(c) => i32::from(
|
||||
self.read_math_code(*c).legacy().ok_or_else(|| {
|
||||
self.error("Extended mathchar used as mathchar", self.current)
|
||||
})?
|
||||
),
|
||||
Key::Mathcodenum(c) => self.read_math_code(*c).word(),
|
||||
Key::Parameter(p) => self.read_parameter(*p).width(),
|
||||
Key::Spacefactor => {
|
||||
if self.writing || !self.math.is_empty() {
|
||||
@@ -2166,6 +2177,7 @@ impl Executor {
|
||||
}
|
||||
Meaning::CharGiven(c) => Ok(c as i32),
|
||||
Meaning::MathCharGiven(c) => Ok(c as i32),
|
||||
Meaning::UnicodeMathCharGiven(code) => Ok(code.word()),
|
||||
Meaning::Parameter(p) if p.kind() == Some(RegisterKind::Muskip) => {
|
||||
self.fail("incompatible mu units in integer scan")
|
||||
}
|
||||
@@ -2429,7 +2441,7 @@ impl Executor {
|
||||
}
|
||||
if matches!(first.token.kind, TokenKind::Command(_)) {
|
||||
let value = self.internal_integer_from(first, files)?;
|
||||
return self.bounded(sign * value as i64);
|
||||
return if sign > 0 { Ok(value) } else { self.bounded(-i64::from(value)) };
|
||||
}
|
||||
let radix = match first.token.kind {
|
||||
TokenKind::Character('\'', CatCode::Other) => 8,
|
||||
@@ -3059,6 +3071,12 @@ impl Executor {
|
||||
Primitive::ItalicCorrection => "/".into(),
|
||||
Primitive::Etexversion => "eTeXversion".into(),
|
||||
Primitive::Etexrevision => "eTeXrevision".into(),
|
||||
Primitive::Umathcode => "Umathcode".into(),
|
||||
Primitive::Umathcodenum => "Umathcodenum".into(),
|
||||
Primitive::Umathchar => "Umathchar".into(),
|
||||
Primitive::Umathcharnum => "Umathcharnum".into(),
|
||||
Primitive::Umathchardef => "Umathchardef".into(),
|
||||
Primitive::Umathcharnumdef => "Umathcharnumdef".into(),
|
||||
_ => format!("{p:?}").to_ascii_lowercase(),
|
||||
};
|
||||
format!("{escape}{name}")
|
||||
@@ -3068,6 +3086,9 @@ impl Executor {
|
||||
Meaning::TokenParameter(p) => format!("{escape}{}", p.name()),
|
||||
Meaning::CharGiven(c) => format!("{escape}char\"{c:X}"),
|
||||
Meaning::MathCharGiven(c) => format!("{escape}mathchar\"{c:X}"),
|
||||
Meaning::UnicodeMathCharGiven(code) => format!(
|
||||
"{escape}Umathchar\"{:X}\"{:X}\"{:X}", code.class(), code.family(), code.slot()
|
||||
),
|
||||
Meaning::Register(r) => format!("{escape}{}{}", r.kind.name(), r.index),
|
||||
Meaning::Parameter(p) => format!("{escape}{}", p.name()),
|
||||
Meaning::Font(font) => format!(
|
||||
@@ -3887,7 +3908,7 @@ impl Executor {
|
||||
..token
|
||||
}));
|
||||
}
|
||||
Meaning::MathCharGiven(_) => {
|
||||
Meaning::MathCharGiven(_) | Meaning::UnicodeMathCharGiven(_) => {
|
||||
return self.fail("native math character execution requires math mode");
|
||||
}
|
||||
Meaning::Undefined => {
|
||||
@@ -4160,19 +4181,8 @@ impl Executor {
|
||||
state.assign_delcode(c, n, global);
|
||||
})?;
|
||||
}
|
||||
Some(Mathcode) => {
|
||||
let c = self.integer(files)?;
|
||||
let c = u8::try_from(c)
|
||||
.map_err(|_| self.error("mathcode index must be in 0..255", self.current))?;
|
||||
self.optional_equals(files)?;
|
||||
let n = self.integer(files)?;
|
||||
if !(0..=32768).contains(&n) {
|
||||
return self.fail("mathcode must be in 0..32768");
|
||||
};
|
||||
let equivalent = self.state.mathcode(c) == n as u16;
|
||||
self.assign_equivalence(Key::Mathcode(c), global, equivalent, files, |state| {
|
||||
state.assign_mathcode(c, n as u16, global);
|
||||
})?;
|
||||
Some(p @ (Mathcode | Umathcode | Umathcodenum)) => {
|
||||
self.scan_math_code_assignment(p, global, files)?;
|
||||
}
|
||||
Some(Parshape) => self.scan_paragraph_shape(global, files)?,
|
||||
Some(Setbox) => {
|
||||
@@ -4279,7 +4289,8 @@ impl Executor {
|
||||
)?;
|
||||
}
|
||||
Some(
|
||||
p @ (Chardef | Mathchardef | Countdef | Toksdef | Dimendef | Skipdef | Muskipdef),
|
||||
p @ (Chardef | Mathchardef | Umathchardef | Umathcharnumdef
|
||||
| Countdef | Toksdef | Dimendef | Skipdef | Muskipdef),
|
||||
) => {
|
||||
self.define_shorthand(p, global, files)?;
|
||||
}
|
||||
@@ -4359,7 +4370,8 @@ impl Executor {
|
||||
let key = self.integer_variable(files)?;
|
||||
if matches!(
|
||||
key,
|
||||
Key::Catcode(_) | Key::Mathcode(_) | Key::Sfcode(_) | Key::CaseCode(_, _)
|
||||
Key::Catcode(_) | Key::Mathcode(_) | Key::Mathcodenum(_) | Key::Sfcode(_)
|
||||
| Key::CaseCode(_, _)
|
||||
) {
|
||||
return self.fail("expected assignable integer register, not a code table");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user