핵심 텍스트를 사용하여 NSAttributed 문자열 열을 현명하게 표시하고 있습니다. 잘 작동합니다. 시스템 글꼴을 사용하는 경우 시뮬레이터와 장치 모두에서 지연없이 표시됩니다. 그러나 사용자 정의 글꼴을 사용하면 장치에 내용을 표시하는 데 더 많은 시간이 소요됩니다. 그러나 시뮬레이터에서 결과는 빠릅니다. 특성 사용 문자열을 표시 사용자 글꼴로 NSAttributed 문자열을 표시하는 데 더 많은 시간이 걸립니다.
- (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;
}
내가 다음 코드 줄을 추가하면
,[self.attributedString addAttribute:(NSString *)kCTFontAttributeName
value:(__bridge id)font
range:range];
장치에서 느립니다. 그러나 시뮬레이터에서는 빠릅니다. 이 코드를 추가하지 않으면 텍스트가 시뮬레이터와 장치 모두에 빠르게 표시됩니다.
무엇이 질문입니까? –
@AlbertRenshaw 맞춤 글꼴을 사용해야하므로 기기에서 텍스트를 지체없이 표시하고 싶습니다. 천천히 문제가됩니다. – Sharon
XCode Instruments의 시간 프로파일 링을 사용하는 경우 특정 라인을 지적합니까? 또한, CoreText, CFStuff 및 bridge를 사용해야합니까? – Larme