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
This commit is contained in:
Derek Thurn
2022-05-13 12:42:32 -07:00
committed by Facebook GitHub Bot
parent 5dae5936fc
commit e2dd2e2a6e
@@ -110,6 +110,16 @@ public class ReactFontManager {
}
}
/**
* Equivalent method to {@see addCustomFont(Context, String, int)} which accepts a Typeface
* object.
*/
public void addCustomFont(String fontFamily, @Nullable Typeface font) {
if (font != null) {
mCustomTypefaceCache.put(fontFamily, font);
}
}
/**
* Add additional font family, or replace the exist one in the font memory cache.
*