diff --git a/packages/examples/src/fontFamilyFallback/index.jsx b/packages/examples/src/fontFamilyFallback/index.jsx index bd249543a..148bdf034 100644 --- a/packages/examples/src/fontFamilyFallback/index.jsx +++ b/packages/examples/src/fontFamilyFallback/index.jsx @@ -16,8 +16,13 @@ const styles = StyleSheet.create({ }, regular: { fontFamily: ['Roboto', 'NotoSansArabic'], + fontSize: '14', fontWeight: 900, }, + default: { + fontFamily: ['Courier-Bold', 'NotoSansArabic'], + fontSize: '14', + }, }); Font.register({ @@ -43,7 +48,19 @@ Font.register({ const MyDoc = () => { return ( - Test امتحان + + This font is default Courier + + + The following is partially Roboto and Noto Sans Arabic + + + Roboto / امتحان + + + The following is partially Courier-Bold and Noto Sans Arabic + + Courier-Bold / امتحان ); }; diff --git a/packages/layout/src/text/fontSubstitution.js b/packages/layout/src/text/fontSubstitution.js index 967cc9985..9ddc982b6 100644 --- a/packages/layout/src/text/fontSubstitution.js +++ b/packages/layout/src/text/fontSubstitution.js @@ -51,10 +51,9 @@ const fontSubstitution = for (let i = 0; i < runs.length; i += 1) { const run = runs[i]; - const defaultFont = - typeof run.attributes.font === 'string' - ? getOrCreateFont(run.attributes.font) - : run.attributes.font; + const defaultFont = run.attributes.font.map((font) => + typeof font === 'string' ? getOrCreateFont(font) : font, + ); if (string.length === 0) { res.push({ start: 0, end: 0, attributes: { font: defaultFont } }); @@ -67,11 +66,7 @@ const fontSubstitution = const char = chars[j]; const codePoint = char.codePointAt(); // If the default font does not have a glyph and the fallback font does, we use it - const font = pickFontFromFontStack( - codePoint, - run.attributes.font, - lastFont, - ); + const font = pickFontFromFontStack(codePoint, defaultFont, lastFont); const fontSize = getFontSize(run); // If anything that would impact res has changed, update it