diff --git a/packages/react-native/React/Views/RCTFont.mm b/packages/react-native/React/Views/RCTFont.mm index 675f40c3131c..b9c1ad26530f 100644 --- a/packages/react-native/React/Views/RCTFont.mm +++ b/packages/react-native/React/Views/RCTFont.mm @@ -24,6 +24,7 @@ RCTFontWeight RCTGetFontWeight(UIFont *font) weightSuffixes = @[ @"normal", @"ultralight", + @"extralight", @"thin", @"light", @"regular", @@ -39,6 +40,7 @@ RCTFontWeight RCTGetFontWeight(UIFont *font) fontWeights = @[ @(UIFontWeightRegular), @(UIFontWeightUltraLight), + @(UIFontWeightUltraLight), @(UIFontWeightThin), @(UIFontWeightLight), @(UIFontWeightRegular), diff --git a/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m b/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m index fc686c65f250..db93a4fd8567 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m @@ -49,6 +49,25 @@ - (void)testWeight } } +- (void)testWeightFromFontName +{ + // "ExtraLight" and "UltraLight" name the same weight (OpenType usWeightClass 200). + { + UIFont *font = [UIFont fontWithName:@"HelveticaNeue-UltraLight" size:14]; + XCTAssertEqual(RCTGetFontWeight(font), UIFontWeightUltraLight); + } +#if !TARGET_OS_TV + { + UIFont *font = [UIFont fontWithName:@"Seravek-ExtraLight" size:14]; + XCTAssertEqual(RCTGetFontWeight(font), UIFontWeightUltraLight); + } + { + UIFont *font = [UIFont fontWithName:@"Seravek-Light" size:14]; + XCTAssertEqual(RCTGetFontWeight(font), UIFontWeightLight); + } +#endif +} + - (void)testSize { {