Reputation: 3560
I want to use Semibold and Bold style of Proxima Nova.
For that I've added Proxima Nova, Proxima Nova Semibold and Proxima Nova Bold fonts to my application Resources.
I have made correct entry in info.plist file and also made sure in Copy Bundle resources.
The way I'm using those Fonts are as below.
[attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Proxima Nova" size:12.0] range:NSMakeRange(0, storypart1.length-1)];
This Works fine for me.
But When I want to use Semibold and Bold style of same font I am getting error.
The way I tried For use Semibold and Bold Style is as below.
[attrString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Proxima Nova-Semibold" size:12.0] range:NSMakeRange(0, storypart1.length-1)];
and
[attrString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Proxima Nova Semibold" size:12.0] range:NSMakeRange(0, storypart1.length-1)];
But in both I am getting following error.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSConcreteMutableAttributedString addAttribute:value:range:: nil value'
Please help me to solve this issue.
Thanks in advance.
Upvotes: 0
Views: 1581
Reputation: 17535
Please first print your font name like this and put your exact bold font name in addributed value and app is getting crash due to font is nil(font not found which you passed). So pass exact same name for bold.
NSLog(@"Font %@",[UIFont fontNamesForFamilyName:@"Proxima Nova"]);
For example
NSLog(@"Font %@",[UIFont fontNamesForFamilyName:@"Arial"]);
Output:
Font (
ArialMT,
"Arial-BoldItalicMT",
"Arial-ItalicMT",
"Arial-BoldMT"
)
Upvotes: 3