diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png index bfa2091b38f525..8294d61c73c743 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testLayoutExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png index 80fca00adcd068..99ec5fe9da62f6 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSliderExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png index 7cf2516faa0db8..e23054a48bf660 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testSwitchExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png index 0eb71334396f1f..519590858d17de 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTabBarExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png index f37869de39ea06..a48719fb5737c3 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testTextExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png index d37b708794c43a..d25cae02ecd48d 100644 Binary files a/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png and b/Examples/UIExplorer/UIExplorerIntegrationTests/ReferenceImages/Examples-UIExplorer-UIExplorerApp.ios/testViewExampleSnapshot_1@2x.png differ diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m index 35dfe1167fbd5a..f986986bebd3c2 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m @@ -41,7 +41,7 @@ - (void)DISABLED_testWeight // task #7118691 - (void)testSize { { - UIFont *expected = [UIFont fontWithName:@"HelveticaNeue" size:18.5]; + UIFont *expected = [UIFont systemFontOfSize:18.5]; UIFont *result = [RCTConvert UIFont:@{@"fontSize": @18.5}]; RCTAssertEqualFonts(expected, result); } @@ -69,12 +69,19 @@ - (void)testFamily - (void)testStyle { { - UIFont *expected = [UIFont fontWithName:@"HelveticaNeue-Italic" size:14]; + UIFont *font = [UIFont systemFontOfSize:14]; + UIFontDescriptor *fontDescriptor = [font fontDescriptor]; + UIFontDescriptorSymbolicTraits symbolicTraits = + fontDescriptor.symbolicTraits; + symbolicTraits |= UIFontDescriptorTraitItalic; + fontDescriptor = + [fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits]; + UIFont *expected = [UIFont fontWithDescriptor:fontDescriptor size:14]; UIFont *result = [RCTConvert UIFont:@{@"fontStyle": @"italic"}]; RCTAssertEqualFonts(expected, result); } { - UIFont *expected = [UIFont fontWithName:@"HelveticaNeue" size:14]; + UIFont *expected = [UIFont systemFontOfSize:14]; UIFont *result = [RCTConvert UIFont:@{@"fontStyle": @"normal"}]; RCTAssertEqualFonts(expected, result); } diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index 31850be5a6e2cb..f32debd47bede8 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -222,7 +222,7 @@ - (BOOL)canBecomeFirstResponder - (UIFont *)defaultPlaceholderFont { - return [UIFont fontWithName:@"Helvetica" size:17]; + return [UIFont systemFontOfSize:17]; } - (UIColor *)defaultPlaceholderTextColor diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 804faf87ece82b..2d647b4652f99e 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -746,7 +746,7 @@ + (UIFont *)UIFont:(UIFont *)font withFamily:(id)family size:(id)size weight:(id)weight style:(id)style { // Defaults - NSString *const RCTDefaultFontFamily = @"Helvetica Neue"; + NSString *const RCTDefaultFontFamily = @"System"; const RCTFontWeight RCTDefaultFontWeight = UIFontWeightRegular; const CGFloat RCTDefaultFontSize = 14; @@ -757,7 +757,59 @@ + (UIFont *)UIFont:(UIFont *)font withFamily:(id)family BOOL isItalic = NO; BOOL isCondensed = NO; + if ([[self NSString:family] isEqualToString:RCTDefaultFontFamily] || + (!family && !font)) { + if (font) { + fontSize = font.pointSize ?: RCTDefaultFontSize; + fontWeight = RCTWeightOfFont(font); + isItalic = RCTFontIsItalic(font); + } + + fontSize = [self CGFloat:size] ?: fontSize; + + if (weight) { + fontWeight = [self RCTFontWeight:weight]; + } + + font = [UIFont systemFontOfSize:fontSize]; + + if (ABS(fontWeight - RCTDefaultFontWeight) < 0.01) { + UIFontDescriptor *fontDescriptor = [font fontDescriptor]; + UIFontDescriptorSymbolicTraits symbolicTraits = + fontDescriptor.symbolicTraits; + + if (style) { + isItalic = [self RCTFontStyle:style]; + } + if (isItalic) { + symbolicTraits |= UIFontDescriptorTraitItalic; + fontDescriptor = + [fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits]; + } + return [UIFont fontWithDescriptor:fontDescriptor size:fontSize]; + } + } + if (font) { + if (!family && !weight) { + fontSize = font.pointSize ?: RCTDefaultFontSize; + fontSize = [self CGFloat:size] ?: fontSize; + + UIFontDescriptor *fontDescriptor = [font fontDescriptor]; + UIFontDescriptorSymbolicTraits symbolicTraits = + fontDescriptor.symbolicTraits; + + if (style) { + isItalic = [self RCTFontStyle:style]; + } + if (isItalic) { + symbolicTraits |= UIFontDescriptorTraitItalic; + fontDescriptor = + [fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits]; + } + return [UIFont fontWithDescriptor:fontDescriptor size:fontSize]; + } + familyName = font.familyName ?: RCTDefaultFontFamily; fontSize = font.pointSize ?: RCTDefaultFontSize; fontWeight = RCTWeightOfFont(font);