mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-29 07:48:17 +08:00
Dynamic Text Sizes for Text component
Summary: Dynamic Text Sizes for Text component. Text gains new prop - allowFontScaling (false by default). There is also AccessibilityManager module that allows you to tune multipliers per each content size category.
This commit is contained in:
@@ -91,7 +91,8 @@ typedef NSURL RCTFileURL;
|
||||
+ (UIFont *)UIFont:(UIFont *)font withStyle:(id)json;
|
||||
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)json;
|
||||
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family
|
||||
size:(id)size weight:(id)weight style:(id)style;
|
||||
size:(id)size weight:(id)weight style:(id)style
|
||||
scaleMultiplier:(CGFloat)scaleMultiplier;
|
||||
|
||||
typedef NSArray NSStringArray;
|
||||
+ (NSStringArray *)NSStringArray:(id)json;
|
||||
|
||||
@@ -779,31 +779,33 @@ static BOOL RCTFontIsCondensed(UIFont *font)
|
||||
withFamily:json[@"fontFamily"]
|
||||
size:json[@"fontSize"]
|
||||
weight:json[@"fontWeight"]
|
||||
style:json[@"fontStyle"]];
|
||||
style:json[@"fontStyle"]
|
||||
scaleMultiplier:1.0f];
|
||||
}
|
||||
|
||||
+ (UIFont *)UIFont:(UIFont *)font withSize:(id)json
|
||||
{
|
||||
return [self UIFont:font withFamily:nil size:json weight:nil style:nil];
|
||||
return [self UIFont:font withFamily:nil size:json weight:nil style:nil scaleMultiplier:1.0];
|
||||
}
|
||||
|
||||
+ (UIFont *)UIFont:(UIFont *)font withWeight:(id)json
|
||||
{
|
||||
return [self UIFont:font withFamily:nil size:nil weight:json style:nil];
|
||||
return [self UIFont:font withFamily:nil size:nil weight:json style:nil scaleMultiplier:1.0];
|
||||
}
|
||||
|
||||
+ (UIFont *)UIFont:(UIFont *)font withStyle:(id)json
|
||||
{
|
||||
return [self UIFont:font withFamily:nil size:nil weight:nil style:json];
|
||||
return [self UIFont:font withFamily:nil size:nil weight:nil style:json scaleMultiplier:1.0];
|
||||
}
|
||||
|
||||
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)json
|
||||
{
|
||||
return [self UIFont:font withFamily:json size:nil weight:nil style:nil];
|
||||
return [self UIFont:font withFamily:json size:nil weight:nil style:nil scaleMultiplier:1.0];
|
||||
}
|
||||
|
||||
+ (UIFont *)UIFont:(UIFont *)font withFamily:(id)family
|
||||
size:(id)size weight:(id)weight style:(id)style
|
||||
scaleMultiplier:(CGFloat)scaleMultiplier
|
||||
{
|
||||
// Defaults
|
||||
NSString *const RCTDefaultFontFamily = @"System";
|
||||
@@ -828,6 +830,9 @@ static BOOL RCTFontIsCondensed(UIFont *font)
|
||||
|
||||
// Get font attributes
|
||||
fontSize = [self CGFloat:size] ?: fontSize;
|
||||
if (scaleMultiplier > 0.0 && scaleMultiplier != 1.0) {
|
||||
fontSize = round(fontSize * scaleMultiplier);
|
||||
}
|
||||
familyName = [self NSString:family] ?: familyName;
|
||||
isItalic = style ? [self RCTFontStyle:style] : isItalic;
|
||||
fontWeight = weight ? [self RCTFontWeight:weight] : fontWeight;
|
||||
|
||||
Reference in New Issue
Block a user