Files
keyboard/Shared/KBFont.m
2025-11-25 15:36:16 +08:00

54 lines
1.1 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// KBFont.m
//
#import "KBFont.h"
#if __OBJC__
@implementation KBFont
+ (UIFont *)fontOfSize:(CGFloat)designSize weight:(UIFontWeight)weight {
// 以 375 设计稿为基准等比缩放(见 KBConfig.h 中的 KBFit
CGFloat scaledSize = KBFit(designSize);
return [UIFont systemFontOfSize:scaledSize weight:weight];
}
+ (UIFont *)regular:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightRegular];
}
+ (UIFont *)medium:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightMedium];
}
+ (UIFont *)semibold:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightSemibold];
}
+ (UIFont *)bold:(CGFloat)designSize {
return [self fontOfSize:designSize weight:UIFontWeightBold];
}
#pragma mark - 语义字体(可按设计自由修改数值)
+ (UIFont *)titleFont {
// 例如18pt半粗体
return [self fontOfSize:18.0 weight:UIFontWeightSemibold];
}
+ (UIFont *)bodyFont {
// 例如14pt常规
return [self regular:14.0];
}
+ (UIFont *)captionFont {
// 例如12pt常规
return [self regular:12.0];
}
@end
#endif