diff --git a/packages/layout/src/text/fontSubstitution.js b/packages/layout/src/text/fontSubstitution.js index 4d2baaac9..637108153 100644 --- a/packages/layout/src/text/fontSubstitution.js +++ b/packages/layout/src/text/fontSubstitution.js @@ -20,9 +20,9 @@ const getOrCreateFont = name => { const getFallbackFont = () => getOrCreateFont('Helvetica'); const shouldFallbackToFont = (codePoint, font) => - !IGNORED_CODE_POINTS.includes(codePoint) && + !font || (!IGNORED_CODE_POINTS.includes(codePoint) && !font.hasGlyphForCodePoint(codePoint) && - getFallbackFont().hasGlyphForCodePoint(codePoint); + getFallbackFont().hasGlyphForCodePoint(codePoint)); const fontSubstitution = () => ({ string, runs }) => { let lastFont = null; diff --git a/packages/layout/src/text/ignoreChars.js b/packages/layout/src/text/ignoreChars.js index f9e15b7d5..5b86ef33c 100644 --- a/packages/layout/src/text/ignoreChars.js +++ b/packages/layout/src/text/ignoreChars.js @@ -5,7 +5,7 @@ const IGNORABLE_CODEPOINTS = [ const buildSubsetForFont = font => IGNORABLE_CODEPOINTS.reduce((acc, codePoint) => { - if (font.hasGlyphForCodePoint && font.hasGlyphForCodePoint(codePoint)) { + if (font && font.hasGlyphForCodePoint && font.hasGlyphForCodePoint(codePoint)) { return acc; } return [...acc, String.fromCharCode(codePoint)];