Skip to content

Commit

Permalink
fix: don’t call hasGlyphForCodePoint if font is null (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverLeighC authored May 22, 2021
1 parent 235dc0a commit eb1a20a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/layout/src/text/fontSubstitution.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/layout/src/text/ignoreChars.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down

0 comments on commit eb1a20a

Please sign in to comment.