mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-16 16:28:39 +00:00
Support more scripts in \text{} environments. (#1076)
* Support more scripts in \text{} environments. This diff is a follow-up to PR #1060 which added support for Indic scripts. In order to support Czech, Turkish and Hungarian text (at least) inside \text{} environments, we need to recognize the Latin Extended A and B Unicode blocks. The patch also adds support for Georgian, and enhances support for Cyrillic by defining the entire Cyrillic unicode block instead of defining symbols for a subset of Cyrillic letters as we did previously. * Only return fontMetrics for supported Unicode scripts in text mode The Unicode scripts listed in unicodeScripts.js are supported in text mode but getCharacterMetrics() was returning fake metrics for them even in math mode. This caused bad handling of \boldsymbol\imath * use Mode from types.js
This commit is contained in:
committed by
Kevin Barabash
parent
5f32b71c85
commit
853e2a4fb7
@@ -33,13 +33,13 @@ import utils from "./utils";
|
||||
* Get the metrics for a given symbol and font, after transformation (i.e.
|
||||
* after following replacement from symbols.js)
|
||||
*/
|
||||
const getMetrics = function(symbol, font) {
|
||||
const getMetrics = function(symbol, font, mode) {
|
||||
if (symbols.math[symbol] && symbols.math[symbol].replace) {
|
||||
return fontMetrics.getCharacterMetrics(
|
||||
symbols.math[symbol].replace, font);
|
||||
symbols.math[symbol].replace, font, mode);
|
||||
} else {
|
||||
return fontMetrics.getCharacterMetrics(
|
||||
symbol, font);
|
||||
symbol, font, mode);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -240,16 +240,16 @@ const makeStackedDelim = function(delim, heightTotal, center, options, mode,
|
||||
}
|
||||
|
||||
// Get the metrics of the four sections
|
||||
const topMetrics = getMetrics(top, font);
|
||||
const topMetrics = getMetrics(top, font, mode);
|
||||
const topHeightTotal = topMetrics.height + topMetrics.depth;
|
||||
const repeatMetrics = getMetrics(repeat, font);
|
||||
const repeatMetrics = getMetrics(repeat, font, mode);
|
||||
const repeatHeightTotal = repeatMetrics.height + repeatMetrics.depth;
|
||||
const bottomMetrics = getMetrics(bottom, font);
|
||||
const bottomMetrics = getMetrics(bottom, font, mode);
|
||||
const bottomHeightTotal = bottomMetrics.height + bottomMetrics.depth;
|
||||
let middleHeightTotal = 0;
|
||||
let middleFactor = 1;
|
||||
if (middle !== null) {
|
||||
const middleMetrics = getMetrics(middle, font);
|
||||
const middleMetrics = getMetrics(middle, font, mode);
|
||||
middleHeightTotal = middleMetrics.height + middleMetrics.depth;
|
||||
middleFactor = 2; // repeat symmetrically above and below middle
|
||||
}
|
||||
@@ -522,7 +522,7 @@ const traverseSequence = function(delim, height, sequence, options) {
|
||||
break;
|
||||
}
|
||||
|
||||
const metrics = getMetrics(delim, delimTypeToFont(sequence[i]));
|
||||
const metrics = getMetrics(delim, delimTypeToFont(sequence[i]), "math");
|
||||
let heightDepth = metrics.height + metrics.depth;
|
||||
|
||||
// Small delimiters are scaled down versions of the same font, so we
|
||||
|
Reference in New Issue
Block a user