Skip to content

Commit e2dd2e2

Browse files
thurnfacebook-github-bot
authored andcommitted
Allows a Typeface object to be added to ReactFontManager
Summary: Currently on Android, React Native can only accept font resource IDs which it internally converts into Typeface objects. This change allows ReactFontManager to be passed a Typeface at runtime to enable e.g. downloading fonts on demand. Changelog: [Android][Added] - Ability to pass a Typeface object to ReactFontManager in addition to a font resource ID Reviewed By: makovkastar Differential Revision: D36138123 fbshipit-source-id: b314e8c7fc28174b5caa017076b6eb3d4f6dbaa8
1 parent 5dae593 commit e2dd2e2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ public void addCustomFont(Context context, String fontFamily, int fontId) {
110110
}
111111
}
112112

113+
/**
114+
* Equivalent method to {@see addCustomFont(Context, String, int)} which accepts a Typeface
115+
* object.
116+
*/
117+
public void addCustomFont(String fontFamily, @Nullable Typeface font) {
118+
if (font != null) {
119+
mCustomTypefaceCache.put(fontFamily, font);
120+
}
121+
}
122+
113123
/**
114124
* Add additional font family, or replace the exist one in the font memory cache.
115125
*

0 commit comments

Comments
 (0)