I'm having a weird bug in iOS 7, I've called it "the fi bug".
Abstract:
The two characters "fi" are considered as one character.
Explanation:
I have created an UILabel with a word in it, as an attributed text.
I created a function that on click colors one character of the word in blue.
(i.e. first click it colors the first character,
second click it colors from the first to the second…).
With iOS 6 simulator no problem at all, when we switch to iOS 7 simulator, everything is okey as long as the word does not contain "fi" on it. For instance when I write "finance", from the first click both f and i are colored in blue.
It does not depend on the 'fi' position, and seems to have the problem only with 'fi'.
code:
The UILabel:@property (strong, nonatomic) IBOutlet UILabel *wordLabel;
The coloring function:
- (void) changeWordLabelWithWord:( NSString *)word to:(int) position{
NSMutableAttributedString *coloredText = [[NSMutableAttributedString alloc] initWithString:word];
[coloredText addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.25 green:0.66 blue:0.96 alpha:1] range:NSMakeRange(0,position)];
_wordLabel.attributedText = coloredText;
}
Thank you for your help and insight ^^.
Cheers !
You can set the "ligature" attribute to zero on your NSMutableAttributedString
.
From the
documentation:
NSLigatureAttributeName
The value of this attribute is an NSNumber object containing an integer. Ligatures cause specific character combinations to be rendered using a single custom glyph that corresponds to those characters. The value 0 indicates no ligatures. The value 1 indicates the use of the default ligatures. The value 2 indicates the use of all ligatures. The default value for this attribute is 1. (Value 2 is unsupported on iOS.)
With the default value 1
, the letters "fi" are rendered as one glyph.
Some fonts even have ligatures for three character sequences such as "ffl".
iOS 7 adds a lot of typographical details. One of them are ligatures: the OS substitutes some character sequences by typographically better one glyph (character) variants.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With