Skip to content

Commit

Permalink
Remove RN Android's bizarre font weight extension pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpetryk committed Nov 21, 2022
1 parent 2160436 commit ce20ba5
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ private static Typeface createAssetTypefaceWithFallbacks(
// Iterate over the list of fontFamilyNames, constructing new FontFamily objects
// for use in the CustomFallbackBuilder below.
for (String fontFamilyName : fontFamilyNames) {
String extension = EXTENSIONS[style];
for (String fileExtension : FILE_EXTENSIONS) {
String fileName =
new StringBuilder()
.append(FONTS_ASSET_PATH)
.append(fontFamilyName)
.append(extension)
.append(fileExtension)
.toString();
try {
Expand All @@ -212,6 +210,11 @@ private static Typeface createAssetTypefaceWithFallbacks(
}
}

// If there's some problem constructing fonts, fall back to the default behavior.
if (fontFamilies.size() == 0) {
return createAssetTypeface(fontFamilyNames[0], style, assetManager);
}

Typeface.CustomFallbackBuilder fallbackBuilder = new Typeface.CustomFallbackBuilder(fontFamilies.get(0));
for (int i = 1; i < fontFamilies.size(); i++) {
fallbackBuilder.addCustomFallback(fontFamilies.get(i));
Expand Down

0 comments on commit ce20ba5

Please sign in to comment.