2012-07-10 156 views
0

由於某些原因,當我顯示單詞「蝴蝶」(或其他任何帶有「fl」)時,「f」和「l」連接在頂部(請參閱圖像如下)。字體是世紀哥特粗體。這是我用來設置UILabel的代碼。標籤的字符串從plist中檢索:相鄰的「f」和「l」字符

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; 

任何想法爲什麼會發生這種情況?謝謝。

screenshot

回答

5

它被稱爲連字,它是故意的。如果您使用的是Core Text,則可以使用kCTLigatureAttributeName屬性更改操作系統呈現連字的方式,如果您使用的是NSAttributedString,則可以使用NSLigatureAttributeName

+0

我的問題是一樣的,「f」和「i」與iOS NSString上的字體「Late-Bold」合併。我沒有使用任何CoreText或NSAttributedString。任何幫助? – NaXir 2014-04-19 11:18:20

1

你看到的是被稱爲ligature - 這個想法最初是爲了更容易處理對印刷機(使用一個字形的常用連字符對)金屬塊字距,但現在作爲一個很大程度上的文體決定已經延續到現代時代。

我不確定如何在API中禁用它,但希望這些額外的背景信息可以幫助您找到答案。

0

這是做這個的簡短方法。 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]; 
相關問題