CTFramesetterCreateWithAttributedString を使用して、iOS5 で中国語の文字列を使用してフレームセッターを作成すると非常に遅いことがわかりましたが、iOS4 では高速です。
次のようなテストを実行しました: (chinese.txt には 77571 の中国語文字が含まれ、english.txt には 233727 文字が含まれます)
NSString *englishCtn = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [self documentDirectory], @"english.txt"] encoding:NSUTF8StringEncoding error:nil];
NSAttributedString *englishCtnA = [[NSAttributedString alloc] initWithString:englishCtn];
NSString *chineseCtn = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@", [self documentDirectory], @"chinese.txt"] encoding:NSUTF8StringEncoding error:nil];
NSAttributedString *chineseCtnA = [[NSAttributedString alloc] initWithString:chineseCtn];
double start = [[NSDate date] timeIntervalSince1970];
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)englishCtnA);
NSLog(@"english length:%d time %f", englishCtn.length, ([[NSDate date] timeIntervalSince1970] - start) * 1000);
start = [[NSDate date] timeIntervalSince1970];
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)chineseCtnA);
NSLog(@"chinese length:%d time %f", chineseCtnA.length, ([[NSDate date] timeIntervalSince1970] - start) * 1000);
iOS 5 では、結果は次のようになります。
中国語 長さ:77571 時間:12140.347004
英語の長さ:233727 時間:75.886011
iOS 4 では、結果は次のようになります。
中国語 長さ:77571 時間:53.114176
英語の長さ:233727 時間:55.696011
私は xCode ツールの時間プロファイラーを使用して何が起こるかを確認しました。関数 TRun::GetNextLigatureCandidateCharRange(long) にほとんどの時間がかかることがわかりました。最適化の方法がわかりません。