Merge pull request #11769 from Snuffleupagus/charToGlyph-fontCharCode-range

Ensure that `Font.charToGlyph` won't fail because `String.fromCodePoint` is given an invalid code point (issue 11768)
This commit is contained in:
Tim van der Meij 2020-04-04 14:36:52 +02:00 committed by GitHub
commit 702fec534d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3216,10 +3216,14 @@ var Font = (function FontClosure() {
};
}
var fontChar =
typeof fontCharCode === "number"
? String.fromCodePoint(fontCharCode)
: "";
let fontChar = "";
if (typeof fontCharCode === "number") {
if (fontCharCode <= 0x10ffff) {
fontChar = String.fromCodePoint(fontCharCode);
} else {
warn(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
}
}
var glyph = this.glyphCache[charcode];
if (