I am displaying NSAttributed string column wise using Core Text. It is working fine. When using system font, it is displayed without any delay both in simulator and device. But when using custom font, more time is taken to display the content in device. But in the simulator, the result is quick.
- (void)updateAttributedString
{
// Existing Code
if (self.text != nil)
{
self.attributedString = [[NSMutableAttributedString alloc] initWithString:self.text];
NSRange range = NSMakeRange(0, [self.text length]);
// Regarding Fixed font
// [ self.attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"TAUN_Elango_Abirami" size:20] range:range];//This is my custom font
// Regarding custom Font using below code
if (self.font != nil) {
CTFontRef font = [self createCTFont];
[self.attributedString addAttribute:(NSString *)kCTFontAttributeName
value:(__bridge id)font
range:range];
CFRelease(font);
}
}
}
- (CTFontRef)createCTFont;
{
CTFontRef font = CTFontCreateWithName((CFStringRef)self.fontName, self.pointSize, NULL);
return font;
}
If I add the following line of code,
[self.attributedString addAttribute:(NSString *)kCTFontAttributeName
value:(__bridge id)font
range:range];
displaying the attributed string is slow in device. But, in simulator it is quick. If I don't add that piece of code, the text is displayed quickly in both simulator and device.