diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/assets/ReactFontManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/assets/ReactFontManager.java new file mode 100644 index 00000000000000..7e7df01bd140ff --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/assets/ReactFontManager.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.common.assets; + +import android.content.Context; +import android.content.res.AssetManager; +import android.graphics.Typeface; +import android.os.Build; +import android.util.SparseArray; +import androidx.annotation.Nullable; +import androidx.core.content.res.ResourcesCompat; +import com.facebook.infer.annotation.Nullsafe; +import java.util.HashMap; +import java.util.Map; + +/** + * 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: + * + *