mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS][ADDED] - Update font to handle system condensed variant Pull Request resolved: https://github.com/facebook/react-native/pull/43188 Test Plan: ``` <Text style={{ fontSize: 28, fontFamily: 'System' }}>System</Text> <Text style={{ fontSize: 28, fontFamily: 'SystemCondensed' }}>SystemCondensed</Text> <Text style={{ fontSize: 28, fontFamily: 'AmericanTypewriter-Condensed' }}>AmericanTypewriter-Condensed</Text> <Text style={{ fontSize: 28, fontFamily: 'HelveticaNeue' }}>HelveticaNeue</Text> <Text style={{ fontSize: 28, fontFamily: 'HelveticaNeue-CondensedBold' }}>HelveticaNeue-CondensedBold</Text> ```  Reviewed By: fabriziocucci Differential Revision: D57329036 Pulled By: javache fbshipit-source-id: b0fffde1a568cb498f907e0a007df4da3e11d586
This commit is contained in:
committed by
Facebook GitHub Bot
parent
524e3eec3e
commit
86dffb3f15
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user