Adjoining “f” and “l” characters

二次信任 提交于 2019-12-08 13:14:54

问题


For some reason, when I display the word "Butterfly" (or anything else with an "fl"), the "f" and the "l" connect at the top (see image below). The font is Century Gothic Bold. This is the code I use to setup the UILabel. The string for the label is retrieved from a plist:

UILabel *label = [[UILabel alloc] init];
label.text = [self.flashcardDelegate.alphabetArr objectAtIndex:index];
label.textColor = [UIColor colorWithRed:.733 green:0 blue:.03137 alpha:1];
label.backgroundColor = [UIColor clearColor];
label.frame = CGRectMake(ipad ? 210.0f : 65.0f, 
                         ipad ? 650.0f : 300.0f, 
                         ipad ? 340.0f : 185.0f, 
                         ipad ? 250.0f : 135.0f);
label.font = [UIFont fontWithName:@"CenturyGothic-Bold" size:ipad ? 200 : 100];
label.textAlignment = UITextAlignmentCenter;

Any idea why this would happen? Thanks.


回答1:


It's called a ligature, and it's intentional. You can change how the OS renders ligatures by using the kCTLigatureAttributeName attribute if you're using Core Text, or you can use NSLigatureAttributeName if you're using NSAttributedString.




回答2:


What you're seeing is known as a ligature - the idea was originally to make it easier to handle the kerning on metal blocks for printing presses (to use one glyph for commonly-joined character pairs), but now has persisted into the modern era as a largely stylistic decision.

I'm unsure how to disable it in the API, but hopefully this additional background information can help you find the answer.




回答3:


Here is a short way of doing this. iOS 6.0+

NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:label.text];
[attributedString addAttribute:NSLigatureAttributeName value:@0 range:NSMakeRange(0, label.text.length)];
[label.text setAttributedText:attributedString];
[attributedString release];


来源:https://stackoverflow.com/questions/11423558/adjoining-f-and-l-characters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!