Disable font scaling when an explicit font handler is set
Reviewed By: sahrens Differential Revision: D7003464 fbshipit-source-id: f36ff344c50a9c63af6c852138041c1c918259c8
This commit is contained in:
parent
cff522d283
commit
f96dfb9468
|
@ -190,7 +190,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
||||||
|
|
||||||
- (CGFloat)effectiveFontSizeMultiplier
|
- (CGFloat)effectiveFontSizeMultiplier
|
||||||
{
|
{
|
||||||
return _allowFontScaling && !isnan(_fontSizeMultiplier) ? _fontSizeMultiplier : 1.0;
|
return !RCTHasFontHandlerSet() && _allowFontScaling && !isnan(_fontSizeMultiplier) ? _fontSizeMultiplier : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (UIColor *)effectiveForegroundColor
|
- (UIColor *)effectiveForegroundColor
|
||||||
|
|
|
@ -20,6 +20,7 @@ typedef UIFont *(^RCTFontHandler)(CGFloat fontSize, NSString *fontWeightDescript
|
||||||
* "semibold", "extrabold", "bold", "heavy", or "black".
|
* "semibold", "extrabold", "bold", "heavy", or "black".
|
||||||
*/
|
*/
|
||||||
RCT_EXTERN void RCTSetDefaultFontHandler(RCTFontHandler handler);
|
RCT_EXTERN void RCTSetDefaultFontHandler(RCTFontHandler handler);
|
||||||
|
RCT_EXTERN BOOL RCTHasFontHandlerSet();
|
||||||
|
|
||||||
@interface RCTFont : NSObject
|
@interface RCTFont : NSObject
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,10 @@ void RCTSetDefaultFontHandler(RCTFontHandler handler) {
|
||||||
defaultFontHandler = handler;
|
defaultFontHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL RCTHasFontHandlerSet() {
|
||||||
|
return defaultFontHandler != nil;
|
||||||
|
}
|
||||||
|
|
||||||
// We pass a string description of the font weight to the defaultFontHandler because UIFontWeight
|
// We pass a string description of the font weight to the defaultFontHandler because UIFontWeight
|
||||||
// is not defined pre-iOS 8.2.
|
// is not defined pre-iOS 8.2.
|
||||||
// Furthermore, UIFontWeight's are lossy floats, so we must use an inexact compare to figure out
|
// Furthermore, UIFontWeight's are lossy floats, so we must use an inexact compare to figure out
|
||||||
|
|
Loading…
Reference in New Issue