Fabric: Fixes custom font of weight is not honored (#47691)

Summary:
Fixes https://github.com/facebook/react-native/issues/47656 .

## Changelog:

[IOS] [FIXED] - Fabric: Fixes custom font of weight is not honored

Pull Request resolved: https://github.com/facebook/react-native/pull/47691

Test Plan: Demo in https://github.com/facebook/react-native/issues/47656

Reviewed By: cipolleschi

Differential Revision: D66174732

Pulled By: javache

fbshipit-source-id: 5e6a8c870d3a13283548c736aed73193f7976bfc
This commit is contained in:
zhongwuzw 2024-11-19 14:06:20 -08:00 committed by Facebook GitHub Bot
parent 156454ef39
commit 933356e2a6

View File

@ -170,12 +170,15 @@ UIFont *RCTFontWithFontProperties(RCTFontProperties fontProperties)
// Gracefully handle being given a font name rather than font family, for
// example: "Helvetica Light Oblique" rather than just "Helvetica".
font = [UIFont fontWithName:fontProperties.family size:effectiveFontSize];
if (!font) {
if (font) {
fontNames = [UIFont fontNamesForFamilyName:font.familyName];
} else {
// Failback to system font.
font = [UIFont systemFontOfSize:effectiveFontSize weight:fontProperties.weight];
}
} else {
}
if (fontNames.count > 0) {
// Get the closest font that matches the given weight for the fontFamily
CGFloat closestWeight = INFINITY;
for (NSString *name in fontNames) {