Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am drawing a PDF file and cannot figure out how to embed the font into the PDF itself, could anyone help me out? It displays fine on the device however once it is emailed out or printed via AirPrint I just get the fallback 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 much appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
644 views
Welcome To Ask or Share your Answers For Others

1 Answer

I have no idea why, but, on an application I was involved in we had this problem, once we switched from using an open type font to true type font it just worked.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...