我希望能够检测字体的风格(加粗、加重、黑体),但我只能检测到字体是否加粗。
BOOL isBold = (font.fontDescriptor.symbolicTraits & UIFontDescriptorTraitBold)!=0;
UIFontDescriptorSymbolicTraits
中没有黑体或加粗的特征。
一种方法是检查字体名称是否包含字符串“black”或“heavy”,但这似乎不可靠。
有 UIFontWeightTrait
,但它仅适用于 UIFont systemFontOfSize:weight:
。
如果有这些样式可用,我想创建自定义字体并添加一个样式。