From 8c2c142491d22ba3ab1934992d889855e44043ec Mon Sep 17 00:00:00 2001 From: Leonardo YongUk Kim Date: Tue, 16 Jun 2015 05:57:39 +0900 Subject: [PATCH] [Text] Get the default font family programmatically. Summary: Get the default font family programmatically. The default font family is hard coded as Helvetica. Closes #1611 --- .../UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m | 6 +++--- Libraries/Text/RCTTextView.m | 2 +- React/Base/RCTConvert.m | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m index 35dfe1167fbd5a..5ee411ad71dc9c 100644 --- a/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m +++ b/Examples/UIExplorer/UIExplorerUnitTests/RCTConvert_UIFontTests.m @@ -42,7 +42,7 @@ - (void)testSize { { UIFont *expected = [UIFont fontWithName:@"HelveticaNeue" size:18.5]; - UIFont *result = [RCTConvert UIFont:@{@"fontSize": @18.5}]; + UIFont *result = [RCTConvert UIFont:@{@"fontFamily": @"Helvetica Neue", @"fontSize": @18.5}]; RCTAssertEqualFonts(expected, result); } } @@ -70,12 +70,12 @@ - (void)testStyle { { UIFont *expected = [UIFont fontWithName:@"HelveticaNeue-Italic" size:14]; - UIFont *result = [RCTConvert UIFont:@{@"fontStyle": @"italic"}]; + UIFont *result = [RCTConvert UIFont:@{@"fontFamily": @"Helvetica Neue", @"fontStyle": @"italic"}]; RCTAssertEqualFonts(expected, result); } { UIFont *expected = [UIFont fontWithName:@"HelveticaNeue" size:14]; - UIFont *result = [RCTConvert UIFont:@{@"fontStyle": @"normal"}]; + UIFont *result = [RCTConvert UIFont:@{@"fontFamily": @"Helvetica Neue", @"fontStyle": @"normal"}]; RCTAssertEqualFonts(expected, result); } } diff --git a/Libraries/Text/RCTTextView.m b/Libraries/Text/RCTTextView.m index fa5b2bf8a9892a..5f58c62ed08178 100644 --- a/Libraries/Text/RCTTextView.m +++ b/Libraries/Text/RCTTextView.m @@ -218,7 +218,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 e244d988bbc9d7..afee01ba1e67d9 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -746,7 +746,8 @@ + (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 = + [UIFont systemFontOfSize:0].familyName; const RCTFontWeight RCTDefaultFontWeight = UIFontWeightRegular; const CGFloat RCTDefaultFontSize = 14;