Skip to content

Commit

Permalink
Merge pull request #32 from discord/fonts/ignore-weight-extension
Browse files Browse the repository at this point in the history
Remove RN Android's bizarre font weight extension pattern
  • Loading branch information
stevenpetryk committed Nov 21, 2022
2 parents 2160436 + ce20ba5 commit e79fc6d
Showing 1 changed file with 5 additions and 2 deletions.
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 e79fc6d

Please sign in to comment.