If no match return at least the first font in the family.

Summary:
Solves issue #7632 where fonts with only a single font weight/type would not render.

Example of a built-in font that would not render is `Zapfino` and other custom fonts like `Impact` would not render.
Closes https://github.com/facebook/react-native/pull/10572

Differential Revision: D4143335

Pulled By: hramos

fbshipit-source-id: 2f64aad2fb5ddc7aae2ca7a5362a89b45e550e13
This commit is contained in:
Roger Chapman 2016-11-07 17:09:52 -08:00 committed by Facebook Github Bot
parent 3eeaffce1a
commit c1458e0181
1 changed files with 9 additions and 0 deletions

View File

@ -301,6 +301,15 @@ RCT_ARRAY_CONVERTER(RCTFontVariantDescriptor)
}
}
// If we still don't have a match at least return the first font in the fontFamily
// This is to support built-in font Zapfino and other custom single font families like Impact
if (!font) {
NSArray *names = [UIFont fontNamesForFamilyName:familyName];
if (names.count > 0) {
font = [UIFont fontWithName:names[0] size:fontSize];
}
}
// Apply font variants to font object
if (variant) {
NSArray *fontFeatures = [RCTConvert RCTFontVariantDescriptorArray:variant];