UNPKG

1.65 kBtext/x-cView Raw
1/*
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#import <Foundation/Foundation.h>
9
10#import <React/RCTConvert.h>
11
12typedef UIFont *(^RCTFontHandler)(CGFloat fontSize, NSString *fontWeightDescription);
13
14/**
15 * React Native will use the System font for rendering by default. If you want to
16 * provide a different base font, use this override. The font weight supplied to your
17 * handler will be one of "ultralight", "thin", "light", "regular", "medium",
18 * "semibold", "extrabold", "bold", "heavy", or "black".
19 */
20RCT_EXTERN void RCTSetDefaultFontHandler(RCTFontHandler handler);
21RCT_EXTERN BOOL RCTHasFontHandlerSet(void);
22
23@interface RCTFont : NSObject
24
25/**
26 * Update a font with a given font-family, size, weight and style.
27 * If parameters are not specified, they'll be kept as-is.
28 * If font is nil, the default system font of size 14 will be used.
29 */
30+ (UIFont *)updateFont:(UIFont *)font
31 withFamily:(NSString *)family
32 size:(NSNumber *)size
33 weight:(NSString *)weight
34 style:(NSString *)style
35 variant:(NSArray<NSString *> *)variant
36 scaleMultiplier:(CGFloat)scaleMultiplier;
37
38+ (UIFont *)updateFont:(UIFont *)font withFamily:(NSString *)family;
39+ (UIFont *)updateFont:(UIFont *)font withSize:(NSNumber *)size;
40+ (UIFont *)updateFont:(UIFont *)font withWeight:(NSString *)weight;
41+ (UIFont *)updateFont:(UIFont *)font withStyle:(NSString *)style;
42
43@end
44
45@interface RCTConvert (RCTFont)
46
47+ (UIFont *)UIFont:(id)json;
48
49@end