Approximate font metrics only when metrics don't exist (#1898)

Fix non-existent metrics error for \eth
This commit is contained in:
ylemkimon
2019-04-07 07:24:32 +09:00
committed by Kevin Barabash
parent a3c95d8c13
commit 7d7c55c4c7
2 changed files with 5 additions and 5 deletions

View File

@@ -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.

View File

@@ -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);
});