简体   繁体   中英

Draw a bold type of font in PDF in ios6

My code is like below but in that,I want to use the font of BOLD type "A/V Calculator" this string is printed in PDF in normal font so anyone can give the solution of this to Print a that text in BOLD style.

my code is given below.

- (void) drawHeader
{
    CGContextRef    currentContext = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0);

    NSString *textToDraw = @"A/V  Calculator";

    UIFont *font = [UIFont systemFontOfSize:24.0];

    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, pageSize.width - 2*kBorderInset - 2*kMarginInset, stringSize.height);

    [textToDraw drawInRect:renderingRect withFont:font  lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentLeft];

}

You can set the font to a specific bold font or `boldSystemFontOfSize. Pass the boldFont to the text that will be bold, and use the other font to draw your other string. Reference: https://discussions.apple.com/thread/1533499?start=0&tstart=0

UIFont *boldFont = [UIFont boldSystemFontOfSize:24.0];
UIFont *normalFont = [UIFont systemFontOfSize:24.0];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM