You can clone with
HTTPS or Subversion.
// fast font creation
matchingFont = CTFontCreateWithFontDescriptor(fontDesc, pointSize, NULL);
This line takes forever, just did a quick Performance-Test with Instruments and this line took ~ 4.5 seconds on my iPhone 4.
No idea what you are talking about. I did extensive testing with instruments.
DTAttributedTextView *textView = [[[DTAttributedTextView alloc] initWithFrame:CGRectMake(10, 25, contentView.frameWidth - 20, 200)] autorelease];
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
// Create attributed string from HTML
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
@"gray", DTDefaultLinkColor, nil];
NSAttributedString *string = [[[NSAttributedString alloc] initWithHTML:data options:options documentAttributes:NULL] autorelease];
Where html is a really short html-string.
Cannot duplicate your result. I copied this HTML into the CurrentTest.html. I copied your options to DemoTextViewController.m. No performance issue. newMatchingFont takes only liek 16.ms, viewDidAppear 40 ms for this file.
I too am trying to figure this out, as it is taking several seconds in my app too. I'll post more when I find what the cause is.
No, Helvetica. Here is a reproducible sample:
NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
[attributes setObject:@"Helvetica" forKey:(id)kCTFontFamilyNameAttribute];
[attributes setObject:[NSNumber numberWithFloat:36.0f] forKey:(id)kCTFontSizeAttribute];
CTFontDescriptorRef fontDesc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
CTFontRef matchingFont = CTFontCreateWithFontDescriptor(fontDesc, 36.0f, NULL);
I don't think it is your issue - it is definitely something to do with iOS. Perhaps introduced in 4.3?
On device is where the problem lies - in simulator it is fine. I have and iPad 2 (6-700ms) and iPad (1200ms) both on 4.3. I don't think I have any devices left below that :)
I have also raised the issue on the Apple dev forums and created a bug report.
Seems strange that it would take that long to load a dynamic lib, but either way I created this gist to use GDC to preload.
Indeed, the bug number is rdar://9350255
Discussion continues here: http://www.cocoanetics.com/2011/04/coretext-loading-performance/
@scarnie Just curious about this: "When I profiled into core text, it is a lot time spent in freetype library". Does it mean that Core Text uses FreeType or is it your extension that uses it?