allow use external typeface in native code
Summary: Expose method to implement changing font family cache. Like ide suggested in #4420 , this will helpful for using remote font file (use `Typeface#createFromFile` to load downloaded font file). iOS's CoreText already allow this in native code. Closes https://github.com/facebook/react-native/pull/4696 Reviewed By: bestander Differential Revision: D2911762 Pulled By: andreicoman11 fb-gh-sync-id: a931e2e711dd94fa0df6fdd066827756d862a4ba
This commit is contained in:
parent
0a6604fa96
commit
17fcc9440f
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue