UIFont+FLEX.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // UIFont+FLEX.m
  3. // FLEX
  4. //
  5. // Created by Tanner Bennett on 12/20/19.
  6. // Copyright © 2020 FLEX Team. All rights reserved.
  7. //
  8. #import "UIFont+FLEX.h"
  9. #if TARGET_OS_TV
  10. #define kFLEXDefaultCellFontSize 24.0
  11. #else
  12. #define kFLEXDefaultCellFontSize 12.0
  13. #endif
  14. @implementation UIFont (FLEX)
  15. + (UIFont *)flex_defaultTableCellFont {
  16. static UIFont *defaultTableCellFont = nil;
  17. static dispatch_once_t onceToken;
  18. dispatch_once(&onceToken, ^{
  19. defaultTableCellFont = [UIFont systemFontOfSize:kFLEXDefaultCellFontSize];
  20. });
  21. return defaultTableCellFont;
  22. }
  23. + (UIFont *)flex_codeFont {
  24. // Actually only available in iOS 13, the SDK headers are wrong
  25. if (@available(iOS 13, *)) {
  26. return [self monospacedSystemFontOfSize:kFLEXDefaultCellFontSize weight:UIFontWeightRegular];
  27. } else {
  28. return [self fontWithName:@"Menlo-Regular" size:kFLEXDefaultCellFontSize];
  29. }
  30. }
  31. + (UIFont *)flex_smallCodeFont {
  32. // Actually only available in iOS 13, the SDK headers are wrong
  33. if (@available(iOS 13, *)) {
  34. return [self monospacedSystemFontOfSize:self.smallSystemFontSize weight:UIFontWeightRegular];
  35. } else {
  36. return [self fontWithName:@"Menlo-Regular" size:self.smallSystemFontSize];
  37. }
  38. }
  39. @end