Parse named math operators as upright text
This commit is contained in:
1 parent
b11fc864f2
commit
639f5e8f8b
2 files changed
+17
No files matched your search
@@ -421,6 +421,10 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
let delimiter = chars.get(next).copied().unwrap_or('|');
|
||||
(MathAtom::Symbol(delimiter), next + 1)
|
||||
}
|
||||
"max" | "min" | "lim" | "log" | "ln" | "sin" | "cos" | "tan" | "cot" | "sec"
|
||||
| "csc" | "exp" | "det" | "dim" | "ker" | "hom" | "arg" | "deg" | "gcd" => {
|
||||
(MathAtom::Text(command.clone()), next)
|
||||
}
|
||||
"text" | "mathrm" => {
|
||||
let mut after = next;
|
||||
if chars.get(after) == Some(&'{') {
|
||||
@@ -527,6 +531,17 @@ mod tests {
|
||||
assert!(indexed.height > plain.height);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn named_operators_use_upright_text_widths() {
|
||||
let font = Cmr10Metrics::default();
|
||||
let max = layout_math(&parse_math("\\max"), &font);
|
||||
let single = layout_math(&parse_math("m"), &font);
|
||||
assert!(max.width > single.width);
|
||||
assert!(matches!(
|
||||
&parse_math("\\max"),
|
||||
MathAtom::Row(atoms) if matches!(&atoms[0], MathAtom::Text(text) if text == "max")
|
||||
));
|
||||
}
|
||||
#[test]
|
||||
fn underline_adds_depth_without_changing_width() {
|
||||
let font = Cmr10Metrics::default();
|
||||
|
||||
Reference in new issue
Block a user