I have a custom font and it doesn't include bold face. I have no problem using it in web and Android since they use faux bold but, I don't know how can I make it bold in iOS. I want to know if there is a way to make faux bold in iOS or any tool to create a bold font face from normal one using techniques that browsers use.
You could use NSAttributedString
to stroke text and make them bold.
Try this code below:
NSString *string = @"Hello World";
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string];
NSDictionary *attributes = @{
NSStrokeWidthAttributeName: @-5.0, //value for making bold, higher negative number bolder text
NSStrokeColorAttributeName:[UIColor blackColor],
NSForegroundColorAttributeName:[UIColor blackColor],
NSFontAttributeName:[UIFont fontWithName:@"Your font name" size:20]
};
[attrString addAttributes:attributes range:NSMakeRange(0, string.length)];
Hope this help.
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.