Skip to content

Commit

Permalink
Allows a Typeface object to be added to ReactFontManager
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thurn authored and facebook-github-bot committed May 13, 2022
1 parent 5dae593 commit e2dd2e2
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public void addCustomFont(Context context, String fontFamily, int fontId) {
}
}

/**
* 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.
*
Expand Down

0 comments on commit e2dd2e2

Please sign in to comment.