Skip to content

Commit ce20ba5

Browse files
committed
Remove RN Android's bizarre font weight extension pattern
1 parent 2160436 commit ce20ba5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,11 @@ private static Typeface createAssetTypefaceWithFallbacks(
189189
// Iterate over the list of fontFamilyNames, constructing new FontFamily objects
190190
// for use in the CustomFallbackBuilder below.
191191
for (String fontFamilyName : fontFamilyNames) {
192-
String extension = EXTENSIONS[style];
193192
for (String fileExtension : FILE_EXTENSIONS) {
194193
String fileName =
195194
new StringBuilder()
196195
.append(FONTS_ASSET_PATH)
197196
.append(fontFamilyName)
198-
.append(extension)
199197
.append(fileExtension)
200198
.toString();
201199
try {
@@ -212,6 +210,11 @@ private static Typeface createAssetTypefaceWithFallbacks(
212210
}
213211
}
214212

213+
// If there's some problem constructing fonts, fall back to the default behavior.
214+
if (fontFamilies.size() == 0) {
215+
return createAssetTypeface(fontFamilyNames[0], style, assetManager);
216+
}
217+
215218
Typeface.CustomFallbackBuilder fallbackBuilder = new Typeface.CustomFallbackBuilder(fontFamilies.get(0));
216219
for (int i = 1; i < fontFamilies.size(); i++) {
217220
fallbackBuilder.addCustomFallback(fontFamilies.get(i));

0 commit comments

Comments
 (0)