我正在尝试使用自定义字体创建新的 PDF。
我加载了我的自定义字体,我可以在所有应用程序中使用它,但是当我尝试使用它创建我的 PDF 时,系统字体被打印出来。
我正在使用 NSString UIKit 添加。
+(UIFont *)imagoBook:(float)size{
return [UIFont fontWithName:@"Imago-Book" size:size];
}
-(NSData *)createPDFfromUIView
{
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, self.bounds, nil);
UIGraphicsBeginPDFPage();
UIFont *imagoBook13 = [ROCTextsInformation imagoBook:13];
[@"Test" drawAtPoint:CGPointZero withFont:imagoBook13];
UIGraphicsEndPDFContext();
// Retrieves the document directories from the iOS device
NSArray* documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString* documentDirectory = [documentDirectories objectAtIndex:0];
NSString* documentDirectoryFilename = [documentDirectory stringByAppendingPathComponent:@"t.pdf"];
// instructs the mutable data object to write its context to a file on disk
[pdfData writeToFile:documentDirectoryFilename atomically:YES];
NSLog(@"documentDirectoryFileName: %@",documentDirectoryFilename);
return pdfData;
}
事实上,我在视图中绘制了相同的上下文,字体写得很好,但不是在 pdf 中。
我正在使用 otf 文件作为字体。
谢谢