ReactFontManager

Responsible for loading and caching Typeface objects.

This will first try to load a typeface from the assets/fonts folder. If one is not found in that folder, this will fallback to the best matching system typeface.

Custom fonts support the extensions .ttf and .otf and the variants bold, italic, and bold_italic. For example, given a font named "ExampleFontFamily", the following are supported:

  • ExampleFontFamily.ttf (or .otf)

  • ExampleFontFamily_bold.ttf (or .otf)

  • ExampleFontFamily_italic.ttf (or .otf)

  • ExampleFontFamily_bold_italic.ttf (or .otf)

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Responsible for normalizing style and numeric weight for backward compatibility.

Functions

Link copied to clipboard
fun addCustomFont(fontFamily: String, font: Typeface?)

Equivalent method to {@see addCustomFont(Context, String, int)} which accepts a Typeface object.

fun addCustomFont(context: Context, fontFamily: String, fontId: Int)
Link copied to clipboard
fun getTypeface(fontFamilyName: String, typefaceStyle: ReactFontManager.TypefaceStyle, assetManager: AssetManager?): Typeface
fun getTypeface(fontFamilyName: String, style: Int, assetManager: AssetManager?): Typeface
fun getTypeface(fontFamilyName: String, weight: Int, italic: Boolean, assetManager: AssetManager?): Typeface
fun getTypeface(fontFamilyName: String, style: Int, weight: Int, assetManager: AssetManager?): Typeface
Link copied to clipboard
fun setTypeface(fontFamilyName: String, style: Int, typeface: Typeface?)

Add additional font family, or replace the exist one in the font memory cache.