I'm trying to create a new PDF with custom font.
I load my custom font and I can use it in all app, but when I tried to use it creating my PDF, the System font is printed.
I'm using NSString UIKit Additions.
+(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;
}
In fact I'm drawing the same context in a view and the font is written perfectly but not in the pdf.
I'm using otf files for the font.
Thankssss
Finally I have solved the problem converting the file .otf to .ttf, and it works!