Skip to content

Commit

Permalink
[Text] Get the default font family programmatically.
Browse files Browse the repository at this point in the history
Summary:
Get the default font family programmatically.
The default font family is hard coded as Helvetica.

Closes facebook#1611
  • Loading branch information
dalinaum committed Jun 15, 2015
1 parent 0c8de68 commit 8c2c142
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Text/RCTTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ - (BOOL)canBecomeFirstResponder

- (UIFont *)defaultPlaceholderFont
{
return [UIFont fontWithName:@"Helvetica" size:17];
return [UIFont systemFontOfSize:17];
}

- (UIColor *)defaultPlaceholderTextColor
Expand Down
3 changes: 2 additions & 1 deletion React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 8c2c142

Please sign in to comment.