2016-08-05 19:29:19 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-08-05 19:29:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTConvert.h>
|
2016-08-05 19:29:19 +00:00
|
|
|
|
2018-01-30 21:31:04 +00:00
|
|
|
typedef UIFont *(^RCTFontHandler)(CGFloat fontSize, NSString *fontWeightDescription);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React Native will use the System font for rendering by default. If you want to
|
|
|
|
* provide a different base font, use this override. The font weight supplied to your
|
|
|
|
* handler will be one of "ultralight", "thin", "light", "regular", "medium",
|
|
|
|
* "semibold", "extrabold", "bold", "heavy", or "black".
|
|
|
|
*/
|
|
|
|
RCT_EXTERN void RCTSetDefaultFontHandler(RCTFontHandler handler);
|
2018-05-02 02:25:06 +00:00
|
|
|
RCT_EXTERN BOOL RCTHasFontHandlerSet(void);
|
2018-01-30 21:31:04 +00:00
|
|
|
|
2016-08-05 19:29:19 +00:00
|
|
|
@interface RCTFont : NSObject
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a font with a given font-family, size, weight and style.
|
|
|
|
* If parameters are not specified, they'll be kept as-is.
|
|
|
|
* If font is nil, the default system font of size 14 will be used.
|
|
|
|
*/
|
|
|
|
+ (UIFont *)updateFont:(UIFont *)font
|
2016-08-05 19:29:21 +00:00
|
|
|
withFamily:(NSString *)family
|
|
|
|
size:(NSNumber *)size
|
|
|
|
weight:(NSString *)weight
|
|
|
|
style:(NSString *)style
|
2016-08-09 15:42:58 +00:00
|
|
|
variant:(NSArray<NSString *> *)variant
|
2016-08-05 19:29:19 +00:00
|
|
|
scaleMultiplier:(CGFloat)scaleMultiplier;
|
|
|
|
|
2016-08-05 19:29:21 +00:00
|
|
|
+ (UIFont *)updateFont:(UIFont *)font withFamily:(NSString *)family;
|
|
|
|
+ (UIFont *)updateFont:(UIFont *)font withSize:(NSNumber *)size;
|
|
|
|
+ (UIFont *)updateFont:(UIFont *)font withWeight:(NSString *)weight;
|
|
|
|
+ (UIFont *)updateFont:(UIFont *)font withStyle:(NSString *)style;
|
2016-08-05 19:29:19 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface RCTConvert (RCTFont)
|
|
|
|
|
|
|
|
+ (UIFont *)UIFont:(id)json;
|
|
|
|
|
|
|
|
@end
|