Skip to content

Commit

Permalink
Fixed Analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Jun 1, 2011
1 parent 9158e49 commit f776077
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 70 deletions.
57 changes: 31 additions & 26 deletions Classes/DTCoreTextFontCollection.m
Expand Up @@ -41,7 +41,7 @@ - (id)initWithAvailableFonts

if (self)
{

}

return self;
Expand All @@ -58,7 +58,7 @@ - (DTCoreTextFontDescriptor *)matchingFontDescriptorForFontDescriptor:(DTCoreTex
{
DTCoreTextFontDescriptor *firstMatch = nil;
NSNumber *cacheKey = [NSString stringWithFormat:@"fontFamily BEGINSWITH[cd] %@ and boldTrait == %d and italicTrait == %d", descriptor.fontFamily, descriptor.boldTrait, descriptor.italicTrait];

// try cache
firstMatch = [self.fontMatchCache objectForKey:cacheKey];

Expand Down Expand Up @@ -107,32 +107,37 @@ - (NSArray *)fontDescriptors
CTFontCollectionRef fonts = CTFontCollectionCreateFromAvailableFonts(NULL);

CFArrayRef matchingFonts = CTFontCollectionCreateMatchingFontDescriptors(fonts);

// 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];
[desc release];
}

self.fontDescriptors = tmpArray;
[tmpArray release];

// cache that

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

return _fontDescriptors;

if (matchingFonts)
{

// 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];
[desc release];
}


CFRelease(matchingFonts);

self.fontDescriptors = tmpArray;
[tmpArray release];
}
}

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

return _fontDescriptors;
}


- (NSCache *)fontMatchCache
{
if (!fontMatchCache)
Expand Down
2 changes: 1 addition & 1 deletion Classes/DTHTMLElement.m
Expand Up @@ -198,7 +198,7 @@ - (NSAttributedString *)attributedString

CTFontRef smallerFont = [smallDesc newMatchingFont];

NSMutableDictionary *smallAttributes = [attributes mutableCopy];
NSMutableDictionary *smallAttributes = [[attributes mutableCopy] autorelease];
[smallAttributes setObject:(id)smallerFont forKey:(id)kCTFontAttributeName];
CFRelease(smallerFont);

Expand Down
4 changes: 2 additions & 2 deletions Classes/DTLazyImageView.m
Expand Up @@ -64,7 +64,7 @@ - (void)cancelLoading
}

#pragma mark Progressive Image
-(CGImageRef)createTransitoryImage:(CGImageRef)partialImg
-(CGImageRef)newTransitoryImage:(CGImageRef)partialImg
{
const size_t height = CGImageGetHeight(partialImg);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
Expand Down Expand Up @@ -97,7 +97,7 @@ - (void)createAndShowProgressiveImage
CGImageRef image = CGImageSourceCreateImageAtIndex(_imageSource, 0, NULL);
if (image)
{
CGImageRef imgTmp = [self createTransitoryImage:image]; // iOS fix to correctly handle JPG see : http://www.cocoabyss.com/mac-os-x/progressive-image-download-imageio/
CGImageRef imgTmp = [self newTransitoryImage:image]; // iOS fix to correctly handle JPG see : http://www.cocoabyss.com/mac-os-x/progressive-image-download-imageio/
if (imgTmp)
{
UIImage *image = [[UIImage alloc] initWithCGImage:imgTmp];
Expand Down
43 changes: 2 additions & 41 deletions Resources/CurrentTest.html
@@ -1,41 +1,2 @@




<div>
<p>normal</p>
<p style="font-size:3em">3em</p>
<p style="font-size:300%">300%</p>
<p style="font-size:xx-small">xx-small</p>
<p style="font-size:x-small">x-small</p>
<p style="font-size:small">small</p>
<p style="font-size:medium">medium</p>
<p style="font-size:large">large</p>
<p style="font-size:x-large">x-large</p>
<p style="font-size:xx-large">xx-large</p>

<big>Big</big>
<big><big>BigBig</big></big>

<div style="font-size:5em">test1</div>
<div style="font-size:1em">test2</div>
<div>test3</div>


<h1>H1</h1>
<h2>H2</h2>
<h3>H3</h3>
<h4>H4</h4>
<h5>H5</h5>
<h6>H6</h6>


</div>

<font size="1">1</font>
<font size="2">2</font>
<font size="3">3</font>
<font size="4">4</font>
<font size="5">5</font>
<font size="6">6</font>
<font size="7">7</font>
<h1>Something</h1>
<p>Something</p>

0 comments on commit f776077

Please sign in to comment.