Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RN Android's bizarre font weight extension pattern #32

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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