I am drawing a PDF file and cannot figure out how to embed the font in the PDF file itself, can someone help me? It displays the device perfectly, but as soon as it is emailed or printed using AirPrint, I just get a spare font. Here is my code ...
- (void) drawChart{
CGContextRef currentContext = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);
NSUserDefaults *data = [NSUserDefaults standardUserDefaults];
NSString *pChart1 = [data stringForKey:@"pchart1"];
NSString *textToDraw = [NSString stringWithFormat:@"%@",pChart1];
UIFont *font = [UIFont fontWithName:@"MyFont" size:14];
CGSize stringSize = [textToDraw sizeWithFont:font
constrainedToSize:CGSizeMake(pageSize.width - 2*kBorderInset-2*kMarginInset, pageSize.height - 2*kBorderInset - 2*kMarginInset)
lineBreakMode:UILineBreakModeWordWrap];
CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset, kBorderInset + kMarginInset + 50.0, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);
[textToDraw drawInRect:renderingRect
withFont:font
lineBreakMode:UILineBreakModeWordWrap
alignment:UITextAlignmentLeft];
}
Any help would be greatly appreciated!
source
share