1

My app has a UILabel formatted as an NSAttributedString with the attribute: 'NSKernAttributeName @1.9,'

  1. When the below code is compiled on iPad running IOS6, the kern works as expected.
  2. When compiled on iPad running IOS7, no kerning occurs.

I have filed Bug at Apple Developer site. #15108371 - No Response yet

NSString *formattedNumber;
NSNumber *scoreNum = [[NSNumber alloc] initWithLongLong:thisScore];
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterPadBeforeSuffix;
formatter.formatWidth = 10;
formatter.paddingCharacter = @"0";
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.usesGroupingSeparator = NO;
formattedNumber = [formatter stringFromNumber:scoreNum];

//Creat atributed string of formated number.
NSShadow *textShadow = [[NSShadow alloc] init];
textShadow.shadowColor = [UIColor colorWithRed:0.5 green:0.7 blue:1 alpha:1.0];
textShadow.shadowBlurRadius = 5.0;
textShadow.shadowOffset = CGSizeMake(0,0);

NSAttributedString  *pHighScoreStyle = [[NSAttributedString alloc] initWithString:formattedNumber attributes: @{
             NSFontAttributeName: [UIFont fontWithName:@"courier" size:16],
  NSForegroundColorAttributeName: [UIColor colorWithRed:0.6 green:0.8 blue:1.0 alpha:0.8],
             NSKernAttributeName: @1.9,
            NSShadowAttributeName: textShadow    }   ];

//Change the disply value.
runningScore.attributedText = pHighScoreStyle;
  • I have the same problem with Kerning working in iOS6 and not working in iOS7. I do not use the UILabel like you but the low level CoreText. Have you heard back from Apple? Did they accept your bug? – naeger Oct 30 '13 at 02:02
  • Nothing from Apple, yet. – user2856384 Nov 03 '13 at 22:53
  • If anyone needs a solution, check it here: http://stackoverflow.com/questions/20580736/how-to-increase-the-character-spacing-in-uilabel/35156300#35156300 – Arben Pnishi Feb 02 '16 at 14:47

1 Answers1

2

OK. I had the same problem (see comment above). It depends on the font (I used Courier as well). For some strange reason Courier does not support kerning (in iOS7!). Use CourierNewPSMT and everything works as expected .... at least for me.

BTW: Here is a nice list of fonts on the iphone: http://iosfonts.com/

naeger
  • 410
  • 3
  • 17