Skip to content

Commit

Permalink
removed disabled caching
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Mar 30, 2013
1 parent 3afbafa commit f4c4ff6
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions Core/Source/DTCoreTextFontCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,42 +99,28 @@ - (NSArray *)fontDescriptors
{
if (!_fontDescriptors)
{
// try caches
CTFontCollectionRef fonts = CTFontCollectionCreateFromAvailableFonts(NULL);

NSString *cachesPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"FontDescriptors.cache"];
CFArrayRef matchingFonts = CTFontCollectionCreateMatchingFontDescriptors(fonts);

self.fontDescriptors = nil;//[NSKeyedUnarchiver unarchiveObjectWithFile:cachesPath];

if (!_fontDescriptors)
if (matchingFonts)
{
CTFontCollectionRef fonts = CTFontCollectionCreateFromAvailableFonts(NULL);

CFArrayRef matchingFonts = CTFontCollectionCreateMatchingFontDescriptors(fonts);
// convert all to our objects
NSMutableArray *tmpArray = [[NSMutableArray alloc] init];

if (matchingFonts)
for (NSInteger i=0; i<CFArrayGetCount(matchingFonts); i++)
{

// convert all to our objects
NSMutableArray *tmpArray = [[NSMutableArray alloc] init];

for (NSInteger i=0; i<CFArrayGetCount(matchingFonts); i++)
{
CTFontDescriptorRef fontDesc = CFArrayGetValueAtIndex(matchingFonts, i);


DTCoreTextFontDescriptor *desc = [[DTCoreTextFontDescriptor alloc] initWithCTFontDescriptor:fontDesc];
[tmpArray addObject:desc];
}
CTFontDescriptorRef fontDesc = CFArrayGetValueAtIndex(matchingFonts, i);


CFRelease(matchingFonts);

self.fontDescriptors = tmpArray;
DTCoreTextFontDescriptor *desc = [[DTCoreTextFontDescriptor alloc] initWithCTFontDescriptor:fontDesc];
[tmpArray addObject:desc];
}

CFRelease(matchingFonts);

self.fontDescriptors = tmpArray;
}

// cache that
[NSKeyedArchiver archiveRootObject:self.fontDescriptors toFile:cachesPath];
}

return _fontDescriptors;
Expand Down

0 comments on commit f4c4ff6

Please sign in to comment.