Skip to content

Commit

Permalink
allow use external typeface in native code
Browse files Browse the repository at this point in the history
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 #4696

Reviewed By: bestander

Differential Revision: D2911762

Pulled By: andreicoman11

fb-gh-sync-id: a931e2e711dd94fa0df6fdd066827756d862a4ba
  • Loading branch information
sospartan authored and facebook-github-bot-5 committed Feb 8, 2016
1 parent 0a6604f commit 17fcc94
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ public static ReactFontManager getInstance() {
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,
Expand Down

0 comments on commit 17fcc94

Please sign in to comment.