diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java index 10e2a4d7b..1e63a2094 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java @@ -72,6 +72,25 @@ public class ReactFontManager { return typeface; } + /** + * Add additional font family, or replace the exist one in the font memory cache. + * @param style + * @see {@link Typeface#DEFAULT} + * @see {@link Typeface#BOLD} + * @see {@link Typeface#ITALIC} + * @see {@link Typeface#BOLD_ITALIC} + */ + public void setTypeface(String fontFamilyName, int style, Typeface typeface) { + if (typeface != null) { + FontFamily fontFamily = mFontCache.get(fontFamilyName); + if (fontFamily == null) { + fontFamily = new FontFamily(); + mFontCache.put(fontFamilyName, fontFamily); + } + fontFamily.setTypeface(style, typeface); + } + } + private static @Nullable Typeface createTypeface( String fontFamilyName,