RCTFont.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #import <Foundation/Foundation.h>
  8. #import <React/RCTConvert.h>
  9. typedef UIFont * (^RCTFontHandler)(CGFloat fontSize, NSString *fontWeightDescription);
  10. /**
  11. * React Native will use the System font for rendering by default. If you want to
  12. * provide a different base font, use this override. The font weight supplied to your
  13. * handler will be one of "ultralight", "thin", "light", "regular", "medium",
  14. * "semibold", "extrabold", "bold", "heavy", or "black".
  15. */
  16. RCT_EXTERN void RCTSetDefaultFontHandler(RCTFontHandler handler);
  17. RCT_EXTERN BOOL RCTHasFontHandlerSet(void);
  18. @interface RCTFont : NSObject
  19. /**
  20. * Update a font with a given font-family, size, weight and style.
  21. * If parameters are not specified, they'll be kept as-is.
  22. * If font is nil, the default system font of size 14 will be used.
  23. */
  24. + (UIFont *)updateFont:(UIFont *)font
  25. withFamily:(NSString *)family
  26. size:(NSNumber *)size
  27. weight:(NSString *)weight
  28. style:(NSString *)style
  29. variant:(NSArray<NSString *> *)variant
  30. scaleMultiplier:(CGFloat)scaleMultiplier;
  31. + (UIFont *)updateFont:(UIFont *)font withFamily:(NSString *)family;
  32. + (UIFont *)updateFont:(UIFont *)font withSize:(NSNumber *)size;
  33. + (UIFont *)updateFont:(UIFont *)font withWeight:(NSString *)weight;
  34. + (UIFont *)updateFont:(UIFont *)font withStyle:(NSString *)style;
  35. @end
  36. @interface RCTConvert (RCTFont)
  37. + (UIFont *)UIFont:(id)json;
  38. @end