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

46 lines
1.2 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.h
// 全局字体工具(主 App 与键盘扩展共用)
//
// 说明:
// - 不做系统 Dynamic Type 适配,字号只按设计稿 + 屏幕宽度等比缩放
// - 统一从这里取字体,避免在各处到处写死数字和 weight
//
#ifndef KBFont_h
#define KBFont_h
#if __OBJC__
#import <UIKit/UIKit.h>
#import "KBConfig.h"
NS_ASSUME_NONNULL_BEGIN
@interface KBFont : NSObject
/// 按设计稿字号 + 屏幕宽度缩放,返回系统字体
/// 使用示例label.font = [KBFont fontOfSize:14 weight:UIFontWeightRegular];
+ (UIFont *)fontOfSize:(CGFloat)designSize weight:(UIFontWeight)weight;
/// 常用 weight 封装(设计稿字号)
+ (UIFont *)regular:(CGFloat)designSize;
+ (UIFont *)medium:(CGFloat)designSize;
+ (UIFont *)semibold:(CGFloat)designSize;
+ (UIFont *)bold:(CGFloat)designSize;
/// 根据当前项目大致预设的几个常用语义字号
/// 可以按设计调整里面的数值,不影响调用方
+ (UIFont *)titleFont; // 标题,例如 18pt 半粗
+ (UIFont *)bodyFont; // 正文,例如 14pt 常规
+ (UIFont *)captionFont; // 辅助/备注,例如 12pt 常规
@end
NS_ASSUME_NONNULL_END
#endif /* __OBJC__ */
#endif /* KBFont_h */