mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-12 06:28:40 +00:00
Unicode characters in math render in text mode (#2040)
* Unicode characters in math render in text mode Improve #2031 by rendering all supported Unicode text characters (via supportedCodepoints) in text mode, mimicking wrapping them in `\text`, thereby using metrics of letter M as usual. * Add tests * Improve documentation * Implement review comments
This commit is contained in:
committed by
Kevin Barabash
parent
3b80e0123b
commit
3b6ed48f5b
@@ -971,9 +971,16 @@ export default class Parser {
|
||||
nucleus);
|
||||
}
|
||||
}
|
||||
// All nonmathematical Unicode characters are rendered as if they
|
||||
// are in text mode (wrapped in \text) because that's what it
|
||||
// takes to render them in LaTeX. Setting `mode: this.mode` is
|
||||
// another natural choice (the user requested math mode), but
|
||||
// this makes it more difficult for getCharacterMetrics() to
|
||||
// distinguish Unicode characters without metrics and those for
|
||||
// which we want to simulate the letter M.
|
||||
symbol = {
|
||||
type: "textord",
|
||||
mode: this.mode,
|
||||
mode: "text",
|
||||
loc: SourceLocation.range(nucleus),
|
||||
text,
|
||||
};
|
||||
|
@@ -80,9 +80,8 @@ const makeSymbol = function(
|
||||
metrics.width, classes);
|
||||
} else {
|
||||
// TODO(emily): Figure out a good way to only print this in development
|
||||
typeof console !== "undefined" && console.warn(
|
||||
"No character metrics for '" + value + "' in style '" +
|
||||
fontName + "'");
|
||||
typeof console !== "undefined" && console.warn("No character metrics " +
|
||||
`for '${value}' in style '${fontName}' and mode '${mode}'`);
|
||||
symbolNode = new SymbolNode(value, 0, 0, 0, 0, 0, classes);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user