From 86dffb3f155dc9652f3abc32383643498b3a21b2 Mon Sep 17 00:00:00 2001 From: Donald Roshi Date: Wed, 15 May 2024 05:15:25 -0700 Subject: [PATCH] fix(ios) use condensed system font (#43188) Summary: The current implementation does not support System font variants. Currently the isCondensed variable is always returning false. This pr adds an extra check to support the 'SystemCondensed' font variant on iOS. ## Changelog: [IOS][ADDED] - Update font to handle system condensed variant Pull Request resolved: https://github.com/facebook/react-native/pull/43188 Test Plan: ``` System SystemCondensed AmericanTypewriter-Condensed HelveticaNeue HelveticaNeue-CondensedBold ``` ![Simulator Screenshot - iPhone 15 Pro - 2024-02-26 at 17 56 40](https://github.com/facebook/react-native/assets/63480001/36daea22-2e75-4526-8b2d-f0555fbf2441) Reviewed By: fabriziocucci Differential Revision: D57329036 Pulled By: javache fbshipit-source-id: b0fffde1a568cb498f907e0a007df4da3e11d586 --- packages/react-native/React/Views/RCTFont.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/Views/RCTFont.mm b/packages/react-native/React/Views/RCTFont.mm index bfc273bdf43..a5a84bb2cb3 100644 --- a/packages/react-native/React/Views/RCTFont.mm +++ b/packages/react-native/React/Views/RCTFont.mm @@ -418,12 +418,14 @@ RCT_ARRAY_CONVERTER(RCTFontVariantDescriptor) familyName = [RCTConvert NSString:family] ?: familyName; isItalic = style ? [RCTConvert RCTFontStyle:style] : isItalic; fontWeight = weight ? [RCTConvert RCTFontWeight:weight] : fontWeight; + isCondensed = isCondensed || [familyName isEqualToString:@"SystemCondensed"]; BOOL didFindFont = NO; // Handle system font as special case. This ensures that we preserve // the specific metrics of the standard system font as closely as possible. - if ([familyName isEqual:defaultFontFamily] || [familyName isEqualToString:@"System"]) { + if ([familyName isEqual:defaultFontFamily] || [familyName isEqualToString:@"System"] || + [familyName isEqualToString:@"SystemCondensed"]) { font = cachedSystemFont(fontSize, fontWeight); if (font) { didFindFont = YES;