mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 19:58:40 +00:00
Approximate font metrics only when metrics don't exist (#1898)
Fix non-existent metrics error for \eth
This commit is contained in:
committed by
Kevin Barabash
parent
a3c95d8c13
commit
7d7c55c4c7
@@ -211,10 +211,11 @@ export function getCharacterMetrics(
|
||||
throw new Error(`Font metrics not found for font: ${font}.`);
|
||||
}
|
||||
let ch = character.charCodeAt(0);
|
||||
if (character[0] in extraCharacterMap) {
|
||||
ch = extraCharacterMap[character[0]].charCodeAt(0);
|
||||
}
|
||||
let metrics = metricMap[font][ch];
|
||||
if (!metrics && character[0] in extraCharacterMap) {
|
||||
ch = extraCharacterMap[character[0]].charCodeAt(0);
|
||||
metrics = metricMap[font][ch];
|
||||
}
|
||||
|
||||
if (!metrics && mode === 'text') {
|
||||
// We don't typically have font metrics for Asian scripts.
|
||||
|
@@ -3332,8 +3332,7 @@ describe("Unicode", function() {
|
||||
});
|
||||
|
||||
it("should parse symbols", function() {
|
||||
expect("ð").toParse(); // warns about lacking character metrics
|
||||
expect("£¥ℂℍℑℎℓℕ℘ℙℚℜℝℤℲℵℶℷℸ⅁∀∁∂∃∇∞∠∡∢♠♡♢♣♭♮♯✓°¬‼⋮\u00B7\u00A9").toBuild(strictSettings);
|
||||
expect("£¥ℂℍℑℎℓℕ℘ℙℚℜℝℤℲℵðℶℷℸ⅁∀∁∂∃∇∞∠∡∢♠♡♢♣♭♮♯✓°¬‼⋮\u00B7\u00A9").toBuild(strictSettings);
|
||||
expect("\\text{£¥ℂℍℎ\u00A9\u00AE\uFE0F}").toBuild(strictSettings);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user