【发布时间】:2015-07-20 14:29:56
【问题描述】:
我正在尝试在我的 iOS 应用程序中使用 truetype (.ttf) 字体,但它无法正常工作。我已将字体添加到我的项目中并正确添加了目标。我在应用程序提供的字体下的 info.plist 中添加了字体。我正在使用 NSAttributedString 来显示文本,这是我的代码
UIFont *hrFont = [UIFont fontWithName:@"ocrb" size:18.0];
NSDictionary *hrDict = [NSDictionary dictionaryWithObject:hrFont forKey:NSFontAttributeName];
NSMutableAttributedString *hrAttrString = [[NSMutableAttributedString alloc] initWithString:hrString attributes: hrDict];
UIFont *barcodeFont = [UIFont fontWithName:@"IDAutomation DataBar 34" size:22];
NSDictionary *barcodeDict = [NSDictionary dictionaryWithObject:barcodeFont forKey:NSFontAttributeName];
NSMutableAttributedString *barcodeAttrString = [[NSMutableAttributedString alloc]initWithString: alphaOnly attributes:barcodeDict];
[hrAttrString appendAttributedString:barcodeAttrString];
条形码字体正确显示,但 ocr 字体显示为系统字体。任何帮助将不胜感激。
【问题讨论】:
标签: ios objective-c xcode fonts