mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
fix: consider extralight fonts in RCTGetFontWeight (#57775)
Summary: `RCTGetFontWeight`, as the name suggests, gets a UIFontWeight given the font names. Some font names are called `extralight` which is the same weight as the already-covered `ultralight -> UIFontWeightUltraLight` case. However, they'd incorrectly be classified as `UIFontWeightLight`. This PR fixes that. Note that the `extrabold` case was already covered. ## Changelog: [iOS] [FIXED] - correctly classify extralight fonts as `UIFontWeightUltraLight` in `RCTGetFontWeight` Pull Request resolved: https://github.com/react/react-native/pull/57775 Test Plan: - green CI Reviewed By: javache Differential Revision: D114475029 Pulled By: fabriziocucci fbshipit-source-id: 896fd4ba7f06e27aeb5a8faa1884fe6b4dba2a27
This commit is contained in:
1 parent
63e9c15448
commit
3b5d0a6526
2 files changed
+21
No files matched your search
@@ -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),
|
||||
|
||||
@@ -49,6 +49,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (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
|
||||
{
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user