Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo Nie committed Sep 6, 2017
1 parent ad733ad commit b8753b4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions React/Views/RCTFont.mm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@

#endif

static NSArray *fontNameOrdering = [NSArray arrayWithObjects:
@"normal",
@"ultralight",
@"thin",
@"light",
@"regular",
@"medium",
@"semibold",
@"bold",
@"heavy",
@"black",
nil];

typedef CGFloat RCTFontWeight;
static RCTFontWeight weightOfFont(UIFont *font)
{
Expand All @@ -41,7 +54,6 @@ static RCTFontWeight weightOfFont(UIFont *font)
dispatch_once(&onceToken, ^{
nameToWeight = @{
@"normal": @(UIFontWeightRegular),
@"bold": @(UIFontWeightBold),
@"ultralight": @(UIFontWeightUltraLight),
@"thin": @(UIFontWeightThin),
@"light": @(UIFontWeightLight),
Expand All @@ -51,10 +63,10 @@ static RCTFontWeight weightOfFont(UIFont *font)
@"bold": @(UIFontWeightBold),
@"heavy": @(UIFontWeightHeavy),
@"black": @(UIFontWeightBlack),
};
};
});

for (NSString *name in nameToWeight) {
for (NSString *name in fontNameOrdering) {
if ([font.fontName.lowercaseString hasSuffix:name]) {
return [nameToWeight[name] doubleValue];
}
Expand Down

0 comments on commit b8753b4

Please sign in to comment.