Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Looking real good now - no leaks

  • Loading branch information...
commit 05aa188e2a74836466528a43b975e36115f28867 1 parent 5546904
@dhoerl dhoerl authored
Showing with 305 additions and 524 deletions.
  1. +4 −2 Core/DTCoreText-Prefix.pch
  2. +1 −3 Core/Source/DTAttributedTextCell.h
  3. +1 −10 Core/Source/DTAttributedTextCell.m
  4. +5 −5 Core/Source/DTAttributedTextContentView.h
  5. +13 −18 Core/Source/DTAttributedTextContentView.m
  6. +3 −3 Core/Source/DTAttributedTextView.h
  7. +0 −2  Core/Source/DTAttributedTextView.m
  8. +5 −10 Core/Source/DTCSSListStyle.m
  9. +1 −1  Core/Source/DTCSSStylesheet.h
  10. +4 −9 Core/Source/DTCSSStylesheet.m
  11. +1 −1  Core/Source/DTCoreTextFontCollection.h
  12. +4 −12 Core/Source/DTCoreTextFontCollection.m
  13. +1 −1  Core/Source/DTCoreTextFontDescriptor.h
  14. +22 −105 Core/Source/DTCoreTextFontDescriptor.m
  15. +6 −6 Core/Source/DTCoreTextGlyphRun.h
  16. +3 −8 Core/Source/DTCoreTextGlyphRun.m
  17. +6 −5 Core/Source/DTCoreTextLayoutFrame.h
  18. +35 −31 Core/Source/DTCoreTextLayoutFrame.m
  19. +2 −3 Core/Source/DTCoreTextLayoutLine.h
  20. +17 −26 Core/Source/DTCoreTextLayoutLine.m
  21. +2 −2 Core/Source/DTCoreTextLayouter.h
  22. +8 −15 Core/Source/DTCoreTextLayouter.m
  23. +5 −12 Core/Source/DTCoreTextParagraphStyle.m
  24. +7 −7 Core/Source/DTHTMLElement.h
  25. +27 −56 Core/Source/DTHTMLElement.m
  26. +4 −4 Core/Source/DTLazyImageView.h
  27. +18 −25 Core/Source/DTLazyImageView.m
  28. +1 −1  Core/Source/DTLinkButton.h
  29. +0 −3  Core/Source/DTLinkButton.m
  30. +5 −5 Core/Source/DTTextAttachment.h
  31. +1 −10 Core/Source/DTTextAttachment.m
  32. +4 −4 Core/Source/DTWebVideoView.h
  33. +1 −5 Core/Source/DTWebVideoView.m
  34. +22 −29 Core/Source/NSAttributedString+HTML.m
  35. +1 −1  Core/Source/NSAttributedStringRunDelegates.h
  36. +5 −4 Core/Source/NSAttributedStringRunDelegates.m
  37. +1 −1  Core/Source/NSCharacterSet+HTML.h
  38. +4 −4 Core/Source/NSCharacterSet+HTML.m
  39. +1 −1  Core/Source/NSData+Base64.h
  40. +2 −3 Core/Source/NSData+Base64.m
  41. +1 −1  Core/Source/NSMutableAttributedString+HTML.h
  42. +3 −5 Core/Source/NSMutableAttributedString+HTML.m
  43. +1 −1  Core/Source/NSScanner+HTML.h
  44. +1 −1  Core/Source/NSScanner+HTML.m
  45. +2 −2 Core/Source/NSString+HTML.m
  46. +1 −1  Core/Source/NSString+Paragraphs.h
  47. +1 −1  Core/Source/NSString+Paragraphs.m
  48. +1 −1  Core/Source/NSString+UTF8Cleaner.m
  49. +1 −1  Core/Source/NSURL+HTML.h
  50. +1 −1  Core/Source/UIDevice+DTVersion.h
  51. +2 −2 Core/Test/UnitTest-Prefix.pch
  52. +11 −3 CoreTextExtensions.xcodeproj/project.pbxproj
  53. +6 −3 Demo/DemoApp-Prefix.pch
  54. +1 −1  Demo/Source/DemoAppDelegate.h
  55. +0 −7 Demo/Source/DemoAppDelegate.m
  56. +1 −7 Demo/Source/DemoSnippetsViewController.m
  57. +3 −3 Demo/Source/DemoTextViewController.h
  58. +11 −26 Demo/Source/DemoTextViewController.m
  59. +4 −4 Demo/Source/main.m
View
6 Core/DTCoreText-Prefix.pch
@@ -3,8 +3,10 @@
//
#ifdef __OBJC__
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
+
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
#endif
View
4 Core/Source/DTAttributedTextCell.h
@@ -6,8 +6,6 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <UIKit/UIKit.h>
-
@class DTAttributedTextContentView;
@interface DTAttributedTextCell : UITableViewCell
@@ -18,7 +16,7 @@
NSUInteger _htmlHash; // preserved hash to avoid relayouting for same HTML
}
-@property (nonatomic, retain) NSAttributedString *attributedString;
+@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, readonly) DTAttributedTextContentView *attributedTextContextView;
- (id)initWithReuseIdentifier:(NSString *)reuseIdentifier accessoryType:(UITableViewCellAccessoryType)accessoryType;
View
11 Core/Source/DTAttributedTextCell.m
@@ -44,13 +44,6 @@ - (id)initWithReuseIdentifier:(NSString *)reuseIdentifier accessoryType:(UITable
return self;
}
-- (void)dealloc
-{
- [_attributedString release];
- [_attributedTextContextView release];
-
- [super dealloc];
-}
- (void)layoutSubviews
{
@@ -85,15 +78,13 @@ - (void)setHTMLString:(NSString *)html
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *string = [[NSAttributedString alloc] initWithHTML:data documentAttributes:NULL];
self.attributedString = string;
- [string release];
}
- (void)setAttributedString:(NSAttributedString *)attributedString
{
if (_attributedString != attributedString)
{
- [_attributedString release];
- _attributedString = [attributedString retain];
+ _attributedString = attributedString;
// passthrough
_attributedTextContextView.attributedString = _attributedString;
View
10 Core/Source/DTAttributedTextContentView.h
@@ -87,7 +87,7 @@
unsigned int delegateSupportsNotificationAfterDrawing:1;
} _delegateFlags;
- id <DTAttributedTextContentViewDelegate> _delegate;
+ __unsafe_unretained id <DTAttributedTextContentViewDelegate> _delegate;
}
- (id)initWithAttributedString:(NSAttributedString *)attributedString width:(CGFloat)width;
@@ -99,10 +99,10 @@
- (CGSize)attributedStringSizeThatFits:(CGFloat)width;
-@property (retain) DTCoreTextLayouter *layouter;
-@property (retain) DTCoreTextLayoutFrame *layoutFrame;
+@property (strong) DTCoreTextLayouter *layouter;
+@property (strong) DTCoreTextLayoutFrame *layoutFrame;
-@property (nonatomic, retain) NSMutableSet *customViews;
+@property (nonatomic, strong) NSMutableSet *customViews;
@property (nonatomic, copy) NSAttributedString *attributedString;
@property (nonatomic) UIEdgeInsets edgeInsets;
@@ -112,7 +112,7 @@
@property (nonatomic) CGPoint layoutOffset;
@property (nonatomic) CGSize backgroundOffset;
-@property (nonatomic, assign) IBOutlet id <DTAttributedTextContentViewDelegate> delegate;
+@property (nonatomic, assign) IBOutlet id <DTAttributedTextContentViewDelegate> delegate; // subtle simulator bug - use assign not __unsafe_unretained
@property (nonatomic, assign) dispatch_semaphore_t selfLock;
View
31 Core/Source/DTAttributedTextContentView.m
@@ -20,8 +20,8 @@
@interface DTAttributedTextContentView ()
-@property (nonatomic, retain) NSMutableDictionary *customViewsForLinksIndex;
-@property (nonatomic, retain) NSMutableDictionary *customViewsForAttachmentsIndex;
+@property (nonatomic, strong) NSMutableDictionary *customViewsForLinksIndex;
+@property (nonatomic, strong) NSMutableDictionary *customViewsForAttachmentsIndex;
- (void)removeAllCustomViews;
- (void)removeSubviewsOutsideRect:(CGRect)rect;
@@ -50,6 +50,8 @@ + (Class)layerClass
@end
+static int cv;
+
@implementation DTAttributedTextContentView
@synthesize selfLock;
@@ -88,7 +90,8 @@ - (id)initWithFrame:(CGRect)frame
if ((self = [super initWithFrame:frame]))
{
[self setup];
-
+++cv;
+NSLog(@"cv alloc (%d)", cv);
}
return self;
}
@@ -115,17 +118,11 @@ - (void)awakeFromNib
- (void)dealloc
{
[self removeAllCustomViews];
- [customViews release];
- [customViewsForLinksIndex release];
- [customViewsForAttachmentsIndex release];
- [_layouter release];
- [_layoutFrame release];
- [_attributedString release];
-
dispatch_release(selfLock);
-
- [super dealloc];
+
+NSLog(@"cv DEALLOC (%d)", --cv);
+
}
- (void)layoutSubviewsInRect:(CGRect)rect
@@ -321,6 +318,8 @@ - (void)layoutSubviewsInRect:(CGRect)rect
[CATransaction commit];
}
SYNCHRONIZE_END(SELF)
+
+ [theLayoutFrame dump:@"layoutSubviewsInRect"];
}
- (void)layoutSubviews
@@ -498,7 +497,6 @@ - (void)setAttributedString:(NSAttributedString *)string
{
if (_attributedString != string)
{
- [_attributedString release];
_attributedString = [string copy];
@@ -593,8 +591,7 @@ - (void)setLayouter:(DTCoreTextLayouter *)layouter
{
if (_layouter != layouter)
{
- [_layouter release];
- _layouter = [layouter retain];
+ _layouter = layouter;
}
}
SYNCHRONIZE_END(SELF)
@@ -615,7 +612,6 @@ - (DTCoreTextLayoutFrame *)layoutFrame
rect.size.height = CGFLOAT_OPEN_HEIGHT; // necessary height set as soon as we know it.
_layoutFrame = [theLayouter layoutFrameWithRect:rect range:NSMakeRange(0, 0)];
- [_layoutFrame retain];
}
}
}
@@ -630,9 +626,8 @@ - (void)setLayoutFrame:(DTCoreTextLayoutFrame *)layoutFrame
{
if (_layoutFrame != layoutFrame)
{
- [_layoutFrame release];
- _layoutFrame = [layoutFrame retain];
+ _layoutFrame = layoutFrame;
[self removeAllCustomViewsForLinks];
View
6 Core/Source/DTAttributedTextView.h
@@ -16,11 +16,11 @@
UIView *backgroundView;
}
-@property (nonatomic, retain) NSAttributedString *attributedString;
+@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, readonly) DTAttributedTextContentView *contentView;
-@property (nonatomic, retain) IBOutlet UIView *backgroundView;
+@property (nonatomic, strong) IBOutlet UIView *backgroundView;
-@property (nonatomic, assign) IBOutlet id <DTAttributedTextContentViewDelegate> textDelegate;
+@property (nonatomic, unsafe_unretained) IBOutlet id <DTAttributedTextContentViewDelegate> textDelegate;
@end
View
2  Core/Source/DTAttributedTextView.m
@@ -36,8 +36,6 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
[contentView removeObserver:self forKeyPath:@"frame"];
- [contentView release];
- [super dealloc];
}
- (void)layoutSubviews
View
15 Core/Source/DTCSSListStyle.m
@@ -25,12 +25,12 @@ @implementation DTCSSListStyle
+ (DTCSSListStyle *)listStyleWithStyles:(NSDictionary *)styles
{
- return [[[DTCSSListStyle alloc] initWithStyles:styles] autorelease];
+ return [[DTCSSListStyle alloc] initWithStyles:styles];
}
+ (DTCSSListStyle *)decimalListStyle
{
- DTCSSListStyle *style = [[[DTCSSListStyle alloc] init] autorelease];
+ DTCSSListStyle *style = [[DTCSSListStyle alloc] init];
style.type = DTCSSListStyleTypeDecimal;
style.position = DTCSSListStylePositionOutside;
return style;
@@ -38,7 +38,7 @@ + (DTCSSListStyle *)decimalListStyle
+ (DTCSSListStyle *)discListStyle
{
- DTCSSListStyle *style = [[[DTCSSListStyle alloc] init] autorelease];
+ DTCSSListStyle *style = [[DTCSSListStyle alloc] init];
style.type = DTCSSListStyleTypeDisc;
style.position = DTCSSListStylePositionOutside;
return style;
@@ -46,7 +46,7 @@ + (DTCSSListStyle *)discListStyle
+ (DTCSSListStyle *)inheritedListStyle
{
- DTCSSListStyle *style = [[[DTCSSListStyle alloc] init] autorelease];
+ DTCSSListStyle *style = [[DTCSSListStyle alloc] init];
style.inherit = YES;
return style;
}
@@ -67,12 +67,6 @@ - (id)initWithStyles:(NSDictionary *)styles
return self;
}
-- (void)dealloc
-{
- [_imageName release];
-
- [super dealloc];
-}
// convert string to listStyleType
+ (DTCSSListStyleType)listStyleTypeFromString:(NSString *)string
@@ -298,6 +292,7 @@ - (NSString *)prefixWithCounter:(NSInteger)counter
case DTCSSListStyleTypeImage:
{
token = UNICODE_OBJECT_PLACEHOLDER;
+ break;
}
case DTCSSListStyleTypeCircle:
{
View
2  Core/Source/DTCSSStylesheet.h
@@ -6,7 +6,7 @@
// Copyright (c) 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
@class DTHTMLElement;
View
13 Core/Source/DTCSSStylesheet.m
@@ -16,7 +16,7 @@
@interface DTCSSStylesheet ()
-@property (nonatomic, retain) NSMutableDictionary *styles;
+@property (nonatomic, strong) NSMutableDictionary *styles;
@end
@@ -37,11 +37,6 @@ - (id)initWithStyleBlock:(NSString *)css
return self;
}
-- (void)dealloc
-{
- [_styles release];
- [super dealloc];
-}
- (NSString *)description
{
@@ -127,7 +122,7 @@ - (void)addStyleRule:(NSString *)rule withSelector:(NSString*)selectors
{
NSString *cleanSelector = [selector stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- NSMutableDictionary *ruleDictionary = [[[rule dictionaryOfCSSStyles] mutableCopy] autorelease];
+ NSMutableDictionary *ruleDictionary = [[rule dictionaryOfCSSStyles] mutableCopy];
// need to uncompress because otherwise we might get shorthands and non-shorthands together
[self uncompressShorthands:ruleDictionary];
@@ -137,7 +132,7 @@ - (void)addStyleRule:(NSString *)rule withSelector:(NSString*)selectors
if (existingRulesForSelector)
{
// substitute new rules over old ones
- NSMutableDictionary *tmpDict = [[existingRulesForSelector mutableCopy] autorelease];
+ NSMutableDictionary *tmpDict = [existingRulesForSelector mutableCopy];
// append new rules
[tmpDict addEntriesFromDictionary:ruleDictionary];
@@ -252,7 +247,7 @@ - (NSDictionary *)mergedStyleDictionaryForElement:(DTHTMLElement *)element
if ([styleString length])
{
- NSMutableDictionary *localStyles = [[[styleString dictionaryOfCSSStyles] mutableCopy] autorelease];
+ NSMutableDictionary *localStyles = [[styleString dictionaryOfCSSStyles] mutableCopy];
// need to uncompress because otherwise we might get shorthands and non-shorthands together
[self uncompressShorthands:localStyles];
View
2  Core/Source/DTCoreTextFontCollection.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
@class DTCoreTextFontDescriptor;
View
16 Core/Source/DTCoreTextFontCollection.m
@@ -13,8 +13,8 @@
@interface DTCoreTextFontCollection ()
-@property (nonatomic, retain) NSArray *fontDescriptors;
-@property (nonatomic, retain) NSCache *fontMatchCache;
+@property (nonatomic, strong) NSArray *fontDescriptors;
+@property (nonatomic, strong) NSCache *fontMatchCache;
@end
@@ -46,12 +46,6 @@ - (id)initWithAvailableFonts
return self;
}
-- (void)dealloc
-{
- [_fontDescriptors release];
- [fontMatchCache release];
- [super dealloc];
-}
- (DTCoreTextFontDescriptor *)matchingFontDescriptorForFontDescriptor:(DTCoreTextFontDescriptor *)descriptor
{
@@ -63,7 +57,7 @@ - (DTCoreTextFontDescriptor *)matchingFontDescriptorForFontDescriptor:(DTCoreTex
if (firstMatch)
{
- DTCoreTextFontDescriptor *retMatch = [[firstMatch copy] autorelease];
+ DTCoreTextFontDescriptor *retMatch = [firstMatch copy];
retMatch.pointSize = descriptor.pointSize;
return retMatch;
}
@@ -80,7 +74,7 @@ - (DTCoreTextFontDescriptor *)matchingFontDescriptorForFontDescriptor:(DTCoreTex
firstMatch = [matchingDescriptors objectAtIndex:0];
[self.fontMatchCache setObject:firstMatch forKey:cacheKey];
- DTCoreTextFontDescriptor *retMatch = [[firstMatch copy] autorelease];
+ DTCoreTextFontDescriptor *retMatch = [firstMatch copy];
retMatch.pointSize = descriptor.pointSize;
return retMatch;
@@ -120,14 +114,12 @@ - (NSArray *)fontDescriptors
DTCoreTextFontDescriptor *desc = [[DTCoreTextFontDescriptor alloc] initWithCTFontDescriptor:fontDesc];
[tmpArray addObject:desc];
- [desc release];
}
CFRelease(matchingFonts);
self.fontDescriptors = tmpArray;
- [tmpArray release];
}
}
View
2  Core/Source/DTCoreTextFontDescriptor.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
#import <CoreText/CoreText.h>
View
127 Core/Source/DTCoreTextFontDescriptor.m
@@ -103,12 +103,12 @@ + (NSString *)overrideFontNameforFontFamily:(NSString *)fontFamily bold:(BOOL)bo
+ (DTCoreTextFontDescriptor *)fontDescriptorWithFontAttributes:(NSDictionary *)attributes
{
- return [[[DTCoreTextFontDescriptor alloc] initWithFontAttributes:attributes] autorelease];
+ return [[DTCoreTextFontDescriptor alloc] initWithFontAttributes:attributes];
}
+ (DTCoreTextFontDescriptor *)fontDescriptorForCTFont:(CTFontRef)ctFont
{
- return [[[DTCoreTextFontDescriptor alloc] initWithCTFont:ctFont] autorelease];
+ return [[DTCoreTextFontDescriptor alloc] initWithCTFont:ctFont];
}
- (id)initWithFontAttributes:(NSDictionary *)attributes
@@ -130,20 +130,19 @@ - (id)initWithCTFontDescriptor:(CTFontDescriptorRef)ctFontDescriptor
CFDictionaryRef dict = CTFontDescriptorCopyAttributes(ctFontDescriptor);
CFDictionaryRef traitsDict = CTFontDescriptorCopyAttribute(ctFontDescriptor, kCTFontTraitsAttribute);
- CTFontSymbolicTraits traitsValue = [[(NSDictionary *)traitsDict objectForKey:(id)kCTFontSymbolicTrait] unsignedIntValue];
+ CTFontSymbolicTraits traitsValue = [[(__bridge NSDictionary *)traitsDict objectForKey:(id)kCTFontSymbolicTrait] unsignedIntValue];
+ CFRelease(traitsDict);
self.symbolicTraits = traitsValue;
- [self setFontAttributes:(id)dict];
-
- CFRelease(dict);
- CFRelease(traitsDict);
+ [self setFontAttributes:CFBridgingRelease(dict)];
+ //CFRelease(dict);
// also get family name
CFStringRef familyName = CTFontDescriptorCopyAttribute(ctFontDescriptor, kCTFontFamilyNameAttribute);
- self.fontFamily = (id)familyName;
- CFRelease(familyName);
+ self.fontFamily = CFBridgingRelease(familyName);
+ //CFRelease(familyName);
}
return self;
@@ -158,24 +157,22 @@ - (id)initWithCTFont:(CTFontRef)ctFont
CFDictionaryRef dict = CTFontDescriptorCopyAttributes(fd);
CFDictionaryRef traitsDict = CTFontDescriptorCopyAttribute(fd, kCTFontTraitsAttribute);
- CTFontSymbolicTraits traitsValue = [[(NSDictionary *)traitsDict objectForKey:(id)kCTFontSymbolicTrait] unsignedIntValue];
+ CTFontSymbolicTraits traitsValue = [[(__bridge NSDictionary *)traitsDict objectForKey:(id)kCTFontSymbolicTrait] unsignedIntValue];
+ CFRelease(traitsDict);
+ CFRelease(fd);
self.symbolicTraits = traitsValue;
- [self setFontAttributes:(id)dict];
-
- CFRelease(dict);
- CFRelease(traitsDict);
- CFRelease(fd);
+ [self setFontAttributes:CFBridgingRelease(dict)];
+ //CFRelease(dict);
// also get the family while we're at it
CFStringRef cfStr = CTFontCopyFamilyName(ctFont);
if (cfStr)
{
- self.fontFamily = (NSString *)cfStr;
-
- CFRelease(cfStr);
+ self.fontFamily = CFBridgingRelease(cfStr);
+ //CFRelease(cfStr);
}
}
@@ -183,13 +180,6 @@ - (id)initWithCTFont:(CTFontRef)ctFont
}
-- (void)dealloc
-{
- [fontFamily release];
- [fontName release];
-
- [super dealloc];
-}
- (NSString *)description
{
@@ -371,7 +361,7 @@ - (BOOL)supportsNativeSmallCaps
if (fontFeatures)
{
- for (NSDictionary *oneFeature in (NSArray *)fontFeatures)
+ for (NSDictionary *oneFeature in (__bridge NSArray *)fontFeatures)
{
NSInteger featureTypeIdentifier = [[oneFeature objectForKey:(id)kCTFontFeatureTypeIdentifierKey] integerValue];
@@ -415,7 +405,7 @@ - (CTFontRef)newMatchingFont
NSCache *fontCache = [DTCoreTextFontDescriptor fontCache];
NSString *cacheKey = [attributes description];
- CTFontRef cachedFont = (CTFontRef)[fontCache objectForKey:cacheKey];
+ CTFontRef cachedFont = (__bridge CTFontRef)[fontCache objectForKey:cacheKey];
if (cachedFont)
{
@@ -451,11 +441,11 @@ - (CTFontRef)newMatchingFont
if (usedName)
{
- matchingFont = CTFontCreateWithName((CFStringRef)usedName, pointSize, NULL);
+ matchingFont = CTFontCreateWithName((__bridge CFStringRef)usedName, pointSize, NULL);
}
else
{
- fontDesc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
+ fontDesc = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)attributes);
if (fontFamily)
{
@@ -479,7 +469,7 @@ - (CTFontRef)newMatchingFont
[set addObject:(id)kCTFontFeaturesAttribute];
}
- CTFontDescriptorRef matchingDesc = CTFontDescriptorCreateMatchingFontDescriptor(fontDesc, (CFSetRef)set);
+ CTFontDescriptorRef matchingDesc = CTFontDescriptorCreateMatchingFontDescriptor(fontDesc, (__bridge CFSetRef)set);
if (matchingDesc)
{
@@ -488,7 +478,7 @@ - (CTFontRef)newMatchingFont
}
else
{
- NSLog(@"No matches for %@", (id)fontDesc);
+ NSLog(@"No matches for %@", (__bridge id)fontDesc);
matchingFont = nil;
}
}
@@ -499,85 +489,12 @@ - (CTFontRef)newMatchingFont
if (matchingFont)
{
// cache it
- [fontCache setObject:(id)matchingFont forKey:cacheKey];
+ [fontCache setObject:(__bridge id)(matchingFont) forKey:cacheKey]; // if you CFBridgeRelease you get a crash
}
dispatch_semaphore_signal(fontLock);
return matchingFont;
}
-- (void)normalizeSlow
-{
- NSDictionary *attributes = [self fontAttributes];
-
- CTFontDescriptorRef fontDesc = nil; CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attributes);
-
- if (fontDesc)
- {
- NSSet *set;
-
- if (self.fontFamily)
- {
- set = [NSSet setWithObjects:(id)kCTFontTraitsAttribute, (id)kCTFontFamilyNameAttribute, nil];
- }
- else
- {
- set = [NSSet setWithObjects:(id)kCTFontTraitsAttribute, nil];
- }
-
- CTFontDescriptorRef matchingDesc = CTFontDescriptorCreateMatchingFontDescriptor(fontDesc, (CFSetRef)set);
-
- if (matchingDesc)
- {
- // CFArrayRef matches = CTFontDescriptorCreateMatchingFontDescriptors(fontDesc, (CFSetRef)set);
- //
- // if (matches)
- // {
- // if (CFArrayGetCount(matches))
- // {
- // CTFontDescriptorRef matchingDesc = CFArrayGetValueAtIndex(matches, 0);
-
- CFDictionaryRef attributes = CTFontDescriptorCopyAttributes(matchingDesc);
-
- CFStringRef family = CTFontDescriptorCopyAttribute(matchingDesc, kCTFontFamilyNameAttribute);
- if (family)
- {
- self.fontFamily = (id)family;
- CFRelease(family);
- }
-
- if (attributes)
- {
- [self setFontAttributes:(id)attributes];
- CFRelease(attributes);
- }
- }
- else
- {
- NSLog(@"No matches for %@", (id)fontDesc);
- }
-
- CFRelease(fontDesc);
- }
- else
- {
- NSLog(@"No matches for %@", [self fontAttributes]);
- }
-
-
-}
-
-
-- (CTFontRef)newMatchingFontSlow
-{
- NSDictionary *fontAttributes = [self fontAttributes];
-
- CTFontDescriptorRef fontDesc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)fontAttributes);
- CTFontRef font = CTFontCreateWithFontDescriptor(fontDesc, self.pointSize, NULL);
- CFRelease(fontDesc);
-
- return font;
-}
-
- (NSUInteger)hash
{
if(_hashSet == NO) {
View
12 Core/Source/DTCoreTextGlyphRun.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
#import <CoreText/CoreText.h>
@@ -28,10 +28,10 @@
NSInteger numberOfGlyphs;
const CGPoint *glyphPositionPoints;
- BOOL needToFreeGlyphPositionPoints;
+ BOOL needToFreeGlyphPositionPoints;
- DTCoreTextLayoutLine *_line;
- NSDictionary *attributes;
+ __unsafe_unretained DTCoreTextLayoutLine *_line; // retain cycle, since these objects are retained by the _line
+ __unsafe_unretained NSDictionary *attributes;
NSArray *stringIndices;
DTTextAttachment *_attachment;
@@ -54,13 +54,13 @@
@property (nonatomic, assign, readonly) CGRect frame;
@property (nonatomic, assign, readonly) NSInteger numberOfGlyphs;
-@property (nonatomic, assign, readonly) NSDictionary *attributes;
+@property (nonatomic, assign, readonly) NSDictionary *attributes; // subtle simulator bug - use assign not __unsafe_unretained
@property (nonatomic, assign, readonly) CGFloat ascent;
@property (nonatomic, assign, readonly) CGFloat descent;
@property (nonatomic, assign, readonly) CGFloat leading;
@property (nonatomic, assign, readonly) CGFloat width;
-@property (nonatomic, retain) DTTextAttachment *attachment;
+@property (nonatomic, strong) DTTextAttachment *attachment;
@end
View
11 Core/Source/DTCoreTextGlyphRun.m 100755 → 100644
@@ -53,12 +53,7 @@ - (void)dealloc
CFRelease(_run);
}
- [_attachment release];
- [stringIndices release];
-
dispatch_release(runLock);
-
- [super dealloc];
}
- (NSString *)description
@@ -121,7 +116,7 @@ - (NSArray *)stringIndices
{
[array addObject:[NSNumber numberWithInteger:indices[i]]];
}
- stringIndices = [array retain];
+ stringIndices = array;
}
return stringIndices;
}
@@ -184,7 +179,7 @@ - (NSDictionary *)attributes
{
if (!attributes)
{
- attributes = (NSDictionary *)CTRunGetAttributes(_run);
+ attributes = (__bridge NSDictionary *)CTRunGetAttributes(_run);
}
return attributes;
@@ -196,7 +191,7 @@ - (DTTextAttachment *)attachment
{
if (!_didCheckForAttachmentInAttributes)
{
- _attachment = [[self.attributes objectForKey:@"DTTextAttachment"] retain];
+ _attachment = [self.attributes objectForKey:@"DTTextAttachment"];
_didCheckForAttachmentInAttributes = YES;
}
View
11 Core/Source/DTCoreTextLayoutFrame.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
#import <CoreText/CoreText.h>
@class DTCoreTextLayoutLine;
@@ -47,7 +47,7 @@
- (CGRect)frameOfGlyphAtIndex:(NSInteger)index;
- (NSArray *)linesVisibleInRect:(CGRect)rect; // lines that are intersected, i.e. also incomplete lines
-- (NSArray *)linesContainedInRect:(CGRect)rect; // lines that are fully contained inside of rect
+// unused? - (NSArray *)linesContainedInRect:(CGRect)rect; // lines that are fully contained inside of rect
- (DTCoreTextLayoutLine *)lineContainingIndex:(NSUInteger)index; // line that contains the string index
- (NSArray *)stringIndices;
@@ -60,16 +60,17 @@
- (NSAttributedString *)attributedStringFragment;
// working with Paragraphs
-- (NSArray *)linesInParagraphAtIndex:(NSUInteger)index;
+// unused? - (NSArray *)linesInParagraphAtIndex:(NSUInteger)index;
- (NSUInteger)paragraphIndexContainingStringIndex:(NSUInteger)stringIndex;
- (NSRange)paragraphRangeContainingStringRange:(NSRange)stringRange;
@property (nonatomic, assign, readonly) CGRect frame;
-@property (nonatomic, retain, readonly) NSArray *lines;
-@property (nonatomic, retain, readonly) NSArray *paragraphRanges;
+@property (nonatomic, strong, readonly) NSArray *lines;
+@property (nonatomic, strong, readonly) NSArray *paragraphRanges;
@property (nonatomic, assign) NSInteger tag;
+- (void)dump:(NSString *)msg;
@end
View
66 Core/Source/DTCoreTextLayoutFrame.m 100755 → 100644
@@ -16,7 +16,7 @@
#import "NSString+Paragraphs.h"
-
+static int lf;
// global flag that shows debug frames
static BOOL _DTCoreTextLayoutFramesShouldDrawDebugFrames = NO;
@@ -32,7 +32,7 @@ + (void)setShouldDrawDebugFrames:(BOOL)debugFrames
- (id)initWithFrame:(CGRect)frame layouter:(DTCoreTextLayouter *)layouter range:(NSRange)range
{
self = [super init];
-
+++lf;
if (self)
{
_frame = frame;
@@ -56,7 +56,6 @@ - (id)initWithFrame:(CGRect)frame layouter:(DTCoreTextLayouter *)layouter range:
else
{
// Strange, should have gotten a valid framesetter
- [self release];
return nil;
}
@@ -73,25 +72,27 @@ - (id)initWithFrame:(CGRect)frame layouter:(DTCoreTextLayouter *)layouter
- (void)dealloc
{
+NSLog(@"LAYOUT FRAME DEALLOC (%d) LINES=%d tf=%x fs=%x", --lf, [_lines count], (unsigned int)_textFrame, (unsigned int)_framesetter);
+
+
if (_textFrame)
{
CFRelease(_textFrame);
- _textFrame = NULL;
}
-
- [_lines release];
- [_paragraphRanges release];
-
+
if (_framesetter)
{
CFRelease(_framesetter);
- _framesetter = NULL;
}
-
- [_textAttachments release];
- [_attributedStringFragment release];
-
- [super dealloc];
+
+ for(id foo in _lines) {
+NSLog(@"dtline dealloc count=%ld", CFGetRetainCount((__bridge CFStringRef)foo) );
+ }
+}
+
+- (void)dump:(NSString *)msg
+{
+ for(id foo in _lines) NSLog(@"dtline %@ count=%ld", msg, CFGetRetainCount((__bridge CFStringRef)foo) );
}
- (NSString *)description
@@ -101,30 +102,30 @@ - (NSString *)description
- (void)buildLines
{
- // get lines
- CFArrayRef lines = CTFrameGetLines(_textFrame);
+ // get lines (don't own it so no release)
+ CFArrayRef cflines = CTFrameGetLines(_textFrame);
- if (!lines)
+ if (!cflines)
{
// probably no string set
return;
}
- CGPoint *origins = malloc(sizeof(CGPoint)*[(NSArray *)lines count]);
+ CGPoint *origins = malloc(sizeof(CGPoint)*CFArrayGetCount(cflines));
CTFrameGetLineOrigins(_textFrame, CFRangeMake(0, 0), origins);
- NSMutableArray *tmpLines = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(lines)];;
+ NSMutableArray *tmpLines = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(cflines)];
NSInteger lineIndex = 0;
- for (id oneLine in (NSArray *)lines)
+ for (id oneLine in (__bridge NSArray *)cflines)
{
CGPoint lineOrigin = origins[lineIndex];
lineOrigin.y = _frame.size.height - lineOrigin.y + _frame.origin.y;
lineOrigin.x += _frame.origin.x;
- DTCoreTextLayoutLine *newLine = [[DTCoreTextLayoutLine alloc] initWithLine:(CTLineRef)oneLine layoutFrame:self origin:lineOrigin];
+ DTCoreTextLayoutLine *newLine = [[DTCoreTextLayoutLine alloc] initWithLine:(__bridge CTLineRef)oneLine layoutFrame:self origin:lineOrigin];
/*
// experimental, trying to find out how to get spacing between lines
@@ -134,15 +135,14 @@ - (void)buildLines
NSLog(@"as %f desc %f, lead %f, lineHeight %f, spacing %f", newLine.ascent, newLine.descent, newLine.leading, [newLine lineHeight], spacing);
*/
[tmpLines addObject:newLine];
- [newLine release];
lineIndex++;
}
-
- _lines = tmpLines;
-
free(origins);
-
+
+NSLog(@"_lines[%d] = tmpLines[%d]", [_lines count], [tmpLines count]);
+ _lines = tmpLines;
+
// at this point we can correct the frame if it is open-ended
if ([_lines count] && _frame.size.height == CGFLOAT_OPEN_HEIGHT)
{
@@ -162,6 +162,7 @@ - (void)buildLines
}
}
+#warning leak
- (NSArray *)lines
{
if (!_lines)
@@ -172,6 +173,7 @@ - (NSArray *)lines
return _lines;
}
+#warning leak?
- (NSArray *)linesVisibleInRect:(CGRect)rect
{
NSMutableArray *tmpArray = [NSMutableArray arrayWithCapacity:[self.lines count]];
@@ -202,6 +204,7 @@ - (NSArray *)linesVisibleInRect:(CGRect)rect
return tmpArray;
}
+#if 0 // appears to be unused
- (NSArray *)linesContainedInRect:(CGRect)rect
{
NSMutableArray *tmpArray = [NSMutableArray arrayWithCapacity:[self.lines count]];
@@ -226,6 +229,7 @@ - (NSArray *)linesContainedInRect:(CGRect)rect
return tmpArray;
}
+#endif
- (CGPathRef)path
{
@@ -278,7 +282,6 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
CFRetain(_textFrame);
}
- [self retain];
if (_DTCoreTextLayoutFramesShouldDrawDebugFrames)
{
@@ -327,7 +330,7 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
}
- CGColorRef backgroundColor = (CGColorRef)[oneRun.attributes objectForKey:@"DTBackgroundColor"];
+ CGColorRef backgroundColor = (__bridge CGColorRef)[oneRun.attributes objectForKey:@"DTBackgroundColor"];
NSDictionary *ruleStyle = [oneRun.attributes objectForKey:@"DTHorizontalRuleStyle"];
@@ -375,7 +378,7 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
if (color)
{
- CGContextSetStrokeColorWithColor(context, (CGColorRef)color);
+ CGContextSetStrokeColorWithColor(context, (__bridge CGColorRef)color);
}
else
{
@@ -515,7 +518,6 @@ - (void)drawInContext:(CGContextRef)context drawImages:(BOOL)drawImages
}
}
- [self release];
if (_textFrame)
{
@@ -577,7 +579,7 @@ - (NSArray *)textAttachmentsWithPredicate:(NSPredicate *)predicate
#pragma mark Calculations
- (NSArray *)stringIndices {
- NSMutableArray *array = [NSMutableArray array];
+ NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self.lines count]];
for (DTCoreTextLayoutLine *oneLine in self.lines) {
[array addObjectsFromArray:[oneLine stringIndices]];
}
@@ -660,6 +662,7 @@ - (DTCoreTextLayoutLine *)lineContainingIndex:(NSUInteger)index
return nil;
}
+#if 0 // apparently unused
- (NSArray *)linesInParagraphAtIndex:(NSUInteger)index
{
NSArray *paragraphRanges = self.paragraphRanges;
@@ -702,6 +705,7 @@ - (NSArray *)linesInParagraphAtIndex:(NSUInteger)index
return nil;
}
}
+#endif
#pragma mark Paragraphs
- (NSUInteger)paragraphIndexContainingStringIndex:(NSUInteger)stringIndex
View
5 Core/Source/DTCoreTextLayoutLine.h
@@ -1,12 +1,11 @@
//
-// DTCoreTextLine.h
+// DTCoreTextLayoutLine.h
// CoreTextExtensions
//
// Created by Oliver Drobnik on 1/24/11.
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
#import <CoreText/CoreText.h>
@@ -53,7 +52,7 @@
- (BOOL)correctAttachmentHeights:(CGFloat *)downShift;
@property (nonatomic, assign) CGRect frame;
-@property (nonatomic, retain, readonly) NSArray *glyphRuns;
+@property (nonatomic, strong, readonly) NSArray *glyphRuns;
@property (nonatomic, assign) CGFloat ascent; // needs to be modifyable
@property (nonatomic, assign, readonly) CGFloat descent;
View
43 Core/Source/DTCoreTextLayoutLine.m 100755 → 100644
@@ -1,5 +1,5 @@
//
-// DTCoreTextLine.m
+// DTCoreTextLayoutLine.m
// CoreTextExtensions
//
// Created by Oliver Drobnik on 1/24/11.
@@ -14,7 +14,7 @@
@interface DTCoreTextLayoutLine ()
-@property (nonatomic, retain) NSArray *glyphRuns;
+@property (nonatomic, strong) NSArray *glyphRuns;
@property (nonatomic, assign) dispatch_semaphore_t layoutLock;
@end
@@ -22,15 +22,19 @@ @interface DTCoreTextLayoutLine ()
#define SYNCHRONIZE_START(obj) dispatch_semaphore_wait(layoutLock, DISPATCH_TIME_FOREVER);
#define SYNCHRONIZE_END(obj) dispatch_semaphore_signal(layoutLock);
+static int ll;
+
@implementation DTCoreTextLayoutLine
@synthesize layoutLock;
- (id)initWithLine:(CTLineRef)line layoutFrame:(DTCoreTextLayoutFrame *)layoutFrame origin:(CGPoint)origin;
{
+++ll;
+NSLog(@"LayoutLine alloc (%d)", ll);
if ((self = [super init]))
{
_line = line;
- CFRetain(line);
+ CFRetain(_line);
NSAttributedString *globalString = [layoutFrame attributedStringFragment];
_attributedString = [[globalString attributedSubstringFromRange:[self stringRange]] copy];
@@ -43,14 +47,10 @@ - (id)initWithLine:(CTLineRef)line layoutFrame:(DTCoreTextLayoutFrame *)layoutFr
- (void)dealloc
{
- if (_line)
- {
- CFRelease(_line);
- }
- [_glyphRuns release];
- dispatch_release(layoutLock);
+ CFRelease(_line);
- [super dealloc];
+ dispatch_release(layoutLock);
+NSLog(@"LayoutLine dealloc (%d)", --ll);
}
- (NSString *)description
@@ -239,7 +239,6 @@ - (BOOL)correctAttachmentHeights:(CGFloat *)downShift
[oneRun fixMetricsFromAttachment];
}
- [correctedRuns release];
// return executed shift
if (downShift)
@@ -280,7 +279,7 @@ - (CGFloat)paragraphSpacing
NSRange allRange = NSMakeRange(0, [_attributedString length]);
[_attributedString enumerateAttribute:(id)kCTParagraphStyleAttributeName inRange:allRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
usingBlock:^(id value, NSRange range, BOOL *stop) {
- CTParagraphStyleRef paragraphStyle = (CTParagraphStyleRef)value;
+ CTParagraphStyleRef paragraphStyle = (__bridge CTParagraphStyleRef)value;
float paraSpacing;
@@ -322,7 +321,6 @@ - (CGFloat)lineHeight
}
-
// calculates the extra space that is before every line even though the leading is zero
- (CGFloat)calculatedLeading
{
@@ -331,22 +329,16 @@ - (CGFloat)calculatedLeading
for (DTCoreTextGlyphRun *oneRun in self.glyphRuns)
{
CGFloat tmpLeading = roundf(MAX(0, oneRun.leading));
-
- CGFloat lineHeight = roundf(oneRun.ascent) + roundf(oneRun.descent) + tmpLeading;
- CGFloat ascenderDelta = 0;
-
- if (tmpLeading > 0)
+
+ if (tmpLeading <= 0)
{
// we have not see a non-zero leading ever before, oh well ...
- ascenderDelta = 0;
- }
- else
- {
// for attachments the ascent equals the image height
// so we don't add the 20%
if (!oneRun.attachment)
{
- ascenderDelta = roundf(0.2 * lineHeight);
+ CGFloat lineHeight = roundf(oneRun.ascent) + roundf(oneRun.descent) + tmpLeading;
+ CGFloat ascenderDelta = roundf(0.2 * lineHeight);
if (ascenderDelta > maxAscenderDelta)
{
@@ -370,13 +362,12 @@ - (NSArray *)glyphRuns
NSMutableArray *tmpArray = [[NSMutableArray alloc] initWithCapacity:CFArrayGetCount(runs)];
- for (id oneRun in (NSArray *)runs)
+ for (id oneRun in (__bridge NSArray *)runs)
{
//CGPoint runOrigin = CGPointMake(_baselineOrigin.x + offset, _baselineOrigin.y);
- DTCoreTextGlyphRun *glyphRun = [[DTCoreTextGlyphRun alloc] initWithRun:(CTRunRef)oneRun layoutLine:self offset:offset];
+ DTCoreTextGlyphRun *glyphRun = [[DTCoreTextGlyphRun alloc] initWithRun:(__bridge CTRunRef)oneRun layoutLine:self offset:offset];
[tmpArray addObject:glyphRun];
- [glyphRun release];
offset += glyphRun.frame.size.width;
}
View
4 Core/Source/DTCoreTextLayouter.h 100755 → 100644
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
#import <CoreText/CoreText.h>
@@ -35,7 +35,7 @@
- (DTCoreTextLayoutFrame *)layoutFrameAtIndex:(NSInteger)index;
-@property (nonatomic, retain) NSAttributedString *attributedString;
+@property (nonatomic, strong) NSAttributedString *attributedString;
@property (nonatomic, readonly) CTFramesetterRef framesetter;
View
23 Core/Source/DTCoreTextLayouter.m 100755 → 100644
@@ -10,7 +10,7 @@
@interface DTCoreTextLayouter ()
-@property (nonatomic, retain) NSMutableArray *frames;
+@property (nonatomic, strong) NSMutableArray *frames;
@property (nonatomic, assign) dispatch_semaphore_t selfLock;
- (CTFramesetterRef) framesetter;
@@ -30,7 +30,6 @@ - (id)initWithAttributedString:(NSAttributedString *)attributedString
{
if (!attributedString)
{
- [self autorelease];
return nil;
}
@@ -43,14 +42,9 @@ - (id)initWithAttributedString:(NSAttributedString *)attributedString
- (void)dealloc
{
- [_attributedString release];
- [frames release];
-
[self discardFramesetter];
dispatch_release(selfLock);
-
- [super dealloc];
}
- (NSString *)description
@@ -76,10 +70,11 @@ - (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width
// a temporary frame
- (DTCoreTextLayoutFrame *)layoutFrameWithRect:(CGRect)frame range:(NSRange)range
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- DTCoreTextLayoutFrame *newFrame = [[DTCoreTextLayoutFrame alloc] initWithFrame:frame layouter:self range:range];
- [pool release]; pool = NULL;
- return [newFrame autorelease];
+ DTCoreTextLayoutFrame *newFrame;
+ @autoreleasepool {
+ newFrame = [[DTCoreTextLayoutFrame alloc] initWithFrame:frame layouter:self range:range];
+ };
+ return newFrame;
}
// reusable frame
@@ -104,7 +99,7 @@ - (CTFramesetterRef)framesetter
{
if (!framesetter)
{
- framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)self.attributedString);
+ framesetter = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)self.attributedString);
}
}
SYNCHRONIZE_END(self)
@@ -131,9 +126,7 @@ - (void)setAttributedString:(NSAttributedString *)attributedString
{
if (_attributedString != attributedString)
{
- [_attributedString release];
-
- _attributedString = [attributedString retain];
+ _attributedString = attributedString;
[self discardFramesetter];
}
View
17 Core/Source/DTCoreTextParagraphStyle.m
@@ -21,7 +21,7 @@ @implementation DTCoreTextParagraphStyle
+ (DTCoreTextParagraphStyle *)defaultParagraphStyle
{
- return [[[DTCoreTextParagraphStyle alloc] init] autorelease];
+ return [[DTCoreTextParagraphStyle alloc] init];
}
+ (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle
@@ -41,13 +41,13 @@ + (DTCoreTextParagraphStyle *)paragraphStyleWithCTParagraphStyle:(CTParagraphSty
DTCoreTextParagraphStyle *returnParagraphStyle = NULL;
// this is naughty: CTParagraphStyle has a description
- NSString *key = [(id)ctParagraphStyle description];
+ NSString *key = [(__bridge id)ctParagraphStyle description];
returnParagraphStyle = [_paragraphStyleCache objectForKey:key];
if (!returnParagraphStyle)
{
- returnParagraphStyle = [[[DTCoreTextParagraphStyle alloc] initWithCTParagraphStyle:ctParagraphStyle] autorelease];
+ returnParagraphStyle = [[DTCoreTextParagraphStyle alloc] initWithCTParagraphStyle:ctParagraphStyle];
[_paragraphStyleCache setObject:returnParagraphStyle forKey:key];
}
}
@@ -119,12 +119,6 @@ - (id)initWithCTParagraphStyle:(CTParagraphStyleRef)ctParagraphStyle
return self;
}
-- (void)dealloc
-{
- [_tabStops release];
-
- [super dealloc];
-}
- (CTParagraphStyleRef)createCTParagraphStyle
@@ -170,8 +164,8 @@ - (BOOL)addTabStopAtPosition:(CGFloat)position alignment:(CTTextAlignment)alignm
{
_tabStops = [[NSMutableArray alloc] init];
}
- [_tabStops addObject:(id)tab];
- CFRelease(tab);
+ [_tabStops addObject:CFBridgingRelease(tab)];
+ //CFRelease(tab);
}
return tab ? YES : NO;
@@ -260,7 +254,6 @@ - (void)setTabStops:(NSArray *)tabStops
{
if (tabStops != _tabStops)
{
- [_tabStops release];
_tabStops = [tabStops mutableCopy]; // keep mutability
}
}
View
14 Core/Source/DTHTMLElement.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
@class DTCoreTextParagraphStyle;
@class DTCoreTextFontDescriptor;
@@ -33,7 +33,7 @@ typedef enum
@interface DTHTMLElement : NSObject <NSCopying>
{
- DTHTMLElement *parent;
+ __unsafe_unretained DTHTMLElement *parent;
DTCoreTextFontDescriptor *fontDescriptor;
DTCoreTextParagraphStyle *paragraphStyle;
@@ -82,13 +82,13 @@ typedef enum
NSDictionary *_attributes; // contains all attributes from parsing
}
-@property (nonatomic, assign) DTHTMLElement *parent;
+@property (nonatomic, assign) DTHTMLElement *parent; // subtle simulator bug - use assign not __unsafe_unretained
@property (nonatomic, copy) DTCoreTextFontDescriptor *fontDescriptor;
@property (nonatomic, copy) DTCoreTextParagraphStyle *paragraphStyle;
-@property (nonatomic, retain) DTTextAttachment *textAttachment;
+@property (nonatomic, strong) DTTextAttachment *textAttachment;
@property (nonatomic, copy) NSURL *link;
-@property (nonatomic, retain) UIColor *textColor;
-@property (nonatomic, retain) UIColor *backgroundColor;
+@property (nonatomic, strong) UIColor *textColor;
+@property (nonatomic, strong) UIColor *backgroundColor;
@property (nonatomic, copy) NSString *tagName;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, copy) NSArray *shadows;
@@ -108,7 +108,7 @@ typedef enum
@property (nonatomic, assign) CGSize size;
@property (nonatomic, readonly) NSInteger listDepth;
@property (nonatomic) NSInteger listCounter;
-@property (nonatomic, retain) NSDictionary *attributes;
+@property (nonatomic, strong) NSDictionary *attributes;
- (NSAttributedString *)attributedString;
View
83 Core/Source/DTHTMLElement.m
@@ -21,8 +21,8 @@
@interface DTHTMLElement ()
-@property (nonatomic, retain) NSMutableDictionary *fontCache;
-@property (nonatomic, retain) NSMutableArray *children;
+@property (nonatomic, strong) NSMutableDictionary *fontCache;
+@property (nonatomic, strong) NSMutableArray *children;
- (DTCSSListStyle *)calculatedListStyle;
@@ -48,31 +48,6 @@ - (id)init
-- (void)dealloc
-{
- [fontDescriptor release];
- [paragraphStyle release];
- [textAttachment release];
-
- [_textColor release];
- [backgroundColor release];
-
- [tagName release];
- [text release];
- [link release];
-
- [shadows release];
-
- [_listStyle release];
-
- [_fontCache release];
- [_additionalAttributes release];
-
- [_attributes release];
- [_children release];
-
- [super dealloc];
-}
- (NSDictionary *)attributesDictionary
@@ -92,8 +67,8 @@ - (NSDictionary *)attributesDictionary
{
// need run delegate for sizing
CTRunDelegateRef embeddedObjectRunDelegate = createEmbeddedObjectRunDelegate(textAttachment);
- [tmpDict setObject:(id)embeddedObjectRunDelegate forKey:(id)kCTRunDelegateAttributeName];
- CFRelease(embeddedObjectRunDelegate);
+ [tmpDict setObject:CFBridgingRelease(embeddedObjectRunDelegate) forKey:(id)kCTRunDelegateAttributeName];
+ //CFRelease(embeddedObjectRunDelegate);
// add attachment
[tmpDict setObject:textAttachment forKey:@"DTTextAttachment"];
@@ -112,7 +87,7 @@ - (NSDictionary *)attributesDictionary
{
// try font cache first
NSNumber *key = [NSNumber numberWithInt:[fontDescriptor hash]];
- CTFontRef font = (CTFontRef)[self.fontCache objectForKey:key];
+ CTFontRef font = (__bridge CTFontRef)[self.fontCache objectForKey:key];
if (!font)
{
@@ -120,14 +95,14 @@ - (NSDictionary *)attributesDictionary
if (font)
{
- [self.fontCache setObject:(id)font forKey:key];
- CFRelease(font);
+ [self.fontCache setObject:CFBridgingRelease(font) forKey:key];
}
}
if (font)
{
- [tmpDict setObject:(id)font forKey:(id)kCTFontAttributeName];
+ // __bridge since its already retained elsewhere
+ [tmpDict setObject:(__bridge id)(font) forKey:(id)kCTFontAttributeName];
}
}
@@ -186,8 +161,8 @@ - (NSDictionary *)attributesDictionary
if (paragraphStyle)
{
CTParagraphStyleRef newParagraphStyle = [self.paragraphStyle createCTParagraphStyle];
- [tmpDict setObject:(id)newParagraphStyle forKey:(id)kCTParagraphStyleAttributeName];
- CFRelease(newParagraphStyle);
+ [tmpDict setObject:CFBridgingRelease(newParagraphStyle) forKey:(id)kCTParagraphStyleAttributeName];
+ //CFRelease(newParagraphStyle);
}
// add shadow array if applicable
@@ -217,7 +192,7 @@ - (NSAttributedString *)attributedString
if (textAttachment)
{
// ignore text, use unicode object placeholder
- NSMutableAttributedString *tmpString = [[[NSMutableAttributedString alloc] initWithString:UNICODE_OBJECT_PLACEHOLDER attributes:attributes] autorelease];
+ NSMutableAttributedString *tmpString = [[NSMutableAttributedString alloc] initWithString:UNICODE_OBJECT_PLACEHOLDER attributes:attributes];
BOOL needsNewLineAfter = ![self isContainedInBlockElement];
@@ -240,7 +215,7 @@ - (NSAttributedString *)attributedString
{
if (self.fontVariant == DTHTMLElementFontVariantNormal)
{
- return [[[NSAttributedString alloc] initWithString:text attributes:attributes] autorelease];
+ return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
else
{
@@ -251,13 +226,12 @@ - (NSAttributedString *)attributedString
CTFontRef smallerFont = [smallDesc newMatchingFont];
- NSMutableDictionary *smallAttributes = [[attributes mutableCopy] autorelease];
- [smallAttributes setObject:(id)smallerFont forKey:(id)kCTFontAttributeName];
- CFRelease(smallerFont);
+ NSMutableDictionary *smallAttributes = [attributes mutableCopy];
+ [smallAttributes setObject:CFBridgingRelease(smallerFont) forKey:(id)kCTFontAttributeName];
+ //CFRelease(smallerFont);
- [smallDesc release];
- return [[[NSAttributedString alloc] initWithString:text attributes:smallAttributes] autorelease];
+ return [[NSAttributedString alloc] initWithString:text attributes:smallAttributes];
}
return [NSAttributedString synthesizedSmallCapsAttributedStringWithText:text attributes:attributes];
@@ -278,10 +252,9 @@ - (NSAttributedString *)prefixForListItem
fontDesc.italicTrait = NO;
CTFontRef font = [fontDesc newMatchingFont];
- [fontDesc release];
- [attributes setObject:(id)font forKey:(id)kCTFontAttributeName];
- CFRelease(font);
+ [attributes setObject:CFBridgingRelease(font) forKey:(id)kCTFontAttributeName];
+ //CFRelease(font);
}
// text color for bullet same as text
@@ -293,8 +266,8 @@ - (NSAttributedString *)prefixForListItem
if (paragraphStyle)
{
CTParagraphStyleRef newParagraphStyle = [self.paragraphStyle createCTParagraphStyle];
- [attributes setObject:(id)newParagraphStyle forKey:(id)kCTParagraphStyleAttributeName];
- CFRelease(newParagraphStyle);
+ [attributes setObject:CFBridgingRelease(newParagraphStyle) forKey:(id)kCTParagraphStyleAttributeName];
+ //CFRelease(newParagraphStyle);
}
// get calculated list style
@@ -319,21 +292,21 @@ - (NSAttributedString *)prefixForListItem
}
}
- NSMutableAttributedString *tmpStr = [[[NSMutableAttributedString alloc] initWithString:prefix attributes:attributes] autorelease];
+ NSMutableAttributedString *tmpStr = [[NSMutableAttributedString alloc] initWithString:prefix attributes:attributes];
if (image)
{
// make an attachment for the image
- DTTextAttachment *attachment = [[[DTTextAttachment alloc] init] autorelease];
+ DTTextAttachment *attachment = [[DTTextAttachment alloc] init];
attachment.contents = image;
attachment.contentType = DTTextAttachmentTypeImage;
attachment.displaySize = image.size;
// need run delegate for sizing
CTRunDelegateRef embeddedObjectRunDelegate = createEmbeddedObjectRunDelegate(attachment);
- [attributes setObject:(id)embeddedObjectRunDelegate forKey:(id)kCTRunDelegateAttributeName];
- CFRelease(embeddedObjectRunDelegate);
+ [attributes setObject:CFBridgingRelease(embeddedObjectRunDelegate) forKey:(id)kCTRunDelegateAttributeName];
+ //CFRelease(embeddedObjectRunDelegate);
// add attachment
[attributes setObject:attachment forKey:@"DTTextAttachment"];
@@ -771,7 +744,7 @@ - (id)valueForKeyPathWithInheritance:(NSString *)keyPath
- (DTCSSListStyle *)calculatedListStyle
{
- DTCSSListStyle *style = [[[DTCSSListStyle alloc] init] autorelease];
+ DTCSSListStyle *style = [[DTCSSListStyle alloc] init];
id calcType = [self valueForKeyPathWithInheritance:@"listStyle.type"];
id calcPos = [self valueForKeyPathWithInheritance:@"listStyle.position"];
@@ -849,9 +822,8 @@ - (void)setTextColor:(UIColor *)textColor
{
if (_textColor != textColor)
{
- [_textColor release];
- _textColor = [textColor retain];
+ _textColor = textColor;
isColorInherited = NO;
}
}
@@ -971,8 +943,7 @@ - (void)setAttributes:(NSDictionary *)attributes
{
if (_attributes != attributes)
{
- [_attributes release];
- _attributes = [attributes retain];
+ _attributes = attributes;
// decode size contained in attributes, might be overridden later by CSS size
size = CGSizeMake([[self attributeForKey:@"width"] floatValue], [[self attributeForKey:@"height"] floatValue]);
View
8 Core/Source/DTLazyImageView.h
@@ -6,7 +6,7 @@
// Copyright 2011 . All rights reserved.
//
-#import <Foundation/Foundation.h>
+
#import <ImageIO/ImageIO.h>
@class DTLazyImageView;
@@ -31,13 +31,13 @@
BOOL shouldShowProgressiveDownload;
- id<DTLazyImageViewDelegate> _delegate;
+ __unsafe_unretained id<DTLazyImageViewDelegate> _delegate;
}
-@property (nonatomic, retain) NSURL *url;
+@property (nonatomic, strong) NSURL *url;
@property (nonatomic, assign) BOOL shouldShowProgressiveDownload;
-@property (nonatomic, assign) id<DTLazyImageViewDelegate> delegate;
+@property (nonatomic, assign) id<DTLazyImageViewDelegate> delegate; // subtle simulator bug - use assign not __unsafe_unretained
- (void)cancelLoading;
View
43 Core/Source/DTLazyImageView.m
@@ -17,16 +17,12 @@ @implementation DTLazyImageView
- (void)dealloc
{
self.image = nil;
- [_url release];
- [_receivedData release];
[_connection cancel];
- [_connection release];
if (_imageSource)
CFRelease(_imageSource), _imageSource = NULL;
- [super dealloc];
}
- (void)loadImageAtURL:(NSURL *)url
@@ -36,18 +32,17 @@ - (void)loadImageAtURL:(NSURL *)url
[self performSelectorInBackground:@selector(loadImageAtURL:) withObject:url];
return;
}
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0];
-
- _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
- [_connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
- [_connection start];
-
- CFRunLoopRun();
-
- [request release];
+ @autoreleasepool {
+ NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0];
+
+ _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO];
+ [_connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
+ [_connection start];
+
+ CFRunLoopRun();
+
- [pool drain];
+ }
}
- (void)didMoveToSuperview
@@ -76,9 +71,9 @@ - (void)didMoveToSuperview
- (void)cancelLoading
{
[_connection cancel];
- [_connection release], _connection = nil;
+ _connection = nil;
- [_receivedData release], _receivedData = nil;
+ _receivedData = nil;
}
#pragma mark Progressive Image
@@ -108,7 +103,7 @@ - (void)createAndShowProgressiveImage
/* For progressive download */
const NSUInteger totalSize = [_receivedData length];
- CGImageSourceUpdateData(_imageSource, (CFDataRef)_receivedData, (totalSize == _expectedSize) ? true : false);
+ CGImageSourceUpdateData(_imageSource, (__bridge CFDataRef)_receivedData, (totalSize == _expectedSize) ? true : false);
if (_fullHeight > 0 && _fullWidth > 0)
{
@@ -120,7 +115,6 @@ - (void)createAndShowProgressiveImage
{
UIImage *image = [[UIImage alloc] initWithCGImage:imgTmp];
[self performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];
- [image release];
CGImageRelease(imgTmp);
}
@@ -179,13 +173,12 @@ - (void)completeDownloadWithData:(NSData *)data
[_imageCache setObject:image forKey:_url];
}
- [image release];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
// every time we get an response it might be a forward, so we discard what data we have
- [_receivedData release], _receivedData = nil;
+ _receivedData = nil;
// does not fire for local file URLs
if ([response isKindOfClass:[NSHTTPURLResponse class]])
@@ -236,10 +229,10 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[self performSelectorOnMainThread:@selector(completeDownloadWithData:) withObject:_receivedData waitUntilDone:YES];
- [_receivedData release], _receivedData = nil;
+ _receivedData = nil;
}
- [_connection release], _connection = nil;
+ _connection = nil;
/* For progressive download */
if (_imageSource)
@@ -250,8 +243,8 @@ - (void)connectionDidFinishLoading:(NSURLConnection *)connection
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
- [_connection release], _connection = nil;
- [_receivedData release], _receivedData = nil;
+ _connection = nil;
+ _receivedData = nil;
/* For progressive download */
if (_imageSource)
View
2  Core/Source/DTLinkButton.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
@interface DTLinkButton : UIButton
View
3  Core/Source/DTLinkButton.m
@@ -40,10 +40,7 @@ - (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
- [_url release];
- [_guid release];
- [super dealloc];
}
View
10 Core/Source/DTTextAttachment.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <Foundation/Foundation.h>
+
@class DTHTMLElement;
@@ -35,11 +35,11 @@ typedef enum
@property (nonatomic, assign) CGSize originalSize;
@property (nonatomic, assign) CGSize displaySize;
-@property (nonatomic, retain) id contents;
+@property (nonatomic, strong) id contents;
@property (nonatomic, assign) DTTextAttachmentType contentType;
-@property (nonatomic, retain) NSURL *contentURL;
-@property (nonatomic, retain) NSURL *hyperLinkURL;
-@property (nonatomic, retain) NSDictionary *attributes;
+@property (nonatomic, strong) NSURL *contentURL;
+@property (nonatomic, strong) NSURL *hyperLinkURL;
+@property (nonatomic, strong) NSDictionary *attributes;
+ (DTTextAttachment *)textAttachmentWithElement:(DTHTMLElement *)element options:(NSDictionary *)options;
View
11 Core/Source/DTTextAttachment.m 100755 → 100644
@@ -171,19 +171,10 @@ + (DTTextAttachment *)textAttachmentWithElement:(DTHTMLElement *)element options
attachment.displaySize = adjustedSize;
attachment.attributes = element.attributes;
- return [attachment autorelease];
+ return attachment;
}
-- (void) dealloc
-{
- [contents release];
- [_contentURL release];
- [_hyperLinkURL release];
- [_attributes release];
-
- [super dealloc];
-}
// makes a data URL of the image
- (NSString *)dataURLRepresentation
View
8 Core/Source/DTWebVideoView.h
@@ -6,7 +6,7 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//
-#import <UIKit/UIKit.h>
+
@class DTTextAttachment;
@class DTWebVideoView;
@@ -23,13 +23,13 @@
{
DTTextAttachment *_attachment;
- id <DTWebVideoViewDelegate> _delegate;
+ __unsafe_unretained id <DTWebVideoViewDelegate> _delegate;
UIWebView *_webView;
}
-@property (nonatomic, assign) id <DTWebVideoViewDelegate> delegate;
-@property (nonatomic, retain) DTTextAttachment *attachment;
+@property (nonatomic, assign) id <DTWebVideoViewDelegate> delegate; // subtle simulator bug - use assign not __unsafe_unretained
+@property (nonatomic, strong) DTTextAttachment *attachment;
View
6 Core/Source/DTWebVideoView.m
@@ -45,10 +45,7 @@ - (id)initWithFrame:(CGRect)frame
- (void)dealloc
{
_webView.delegate = nil;
- [_webView release];
- [_attachment release];
- [super dealloc];
}
@@ -102,9 +99,8 @@ - (void)setAttachment:(DTTextAttachment *)attachment
{
if (_attachment != attachment)
{
- [_attachment release];
- _attachment = [attachment retain];
+ _attachment = attachment;
}
switch (attachment.contentType)
View
51 Core/Source/NSAttributedString+HTML.m 100755 → 100644
@@ -7,7 +7,7 @@
//
#import <CoreText/CoreText.h>
-#import <UIKit/UIKit.h>
+
#import "NSAttributedString+HTML.h"
#import "NSMutableAttributedString+HTML.h"
@@ -71,7 +71,6 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
// only with valid data
if (![data length])
{
- [self release];
return nil;
}
@@ -82,7 +81,7 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
if (textEncodingName)
{
- CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)textEncodingName);
+ CFStringEncoding cfEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)textEncodingName);
encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding);
}
@@ -115,12 +114,11 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
{
NSLog(@"No valid HTML passed to to initWithHTML");
- [self release];
return nil;
}
// the combined style sheet for entire document
- DTCSSStylesheet *styleSheet = [[[DTCSSStylesheet alloc] init] autorelease];
+ DTCSSStylesheet *styleSheet = [[DTCSSStylesheet alloc] init];
// default list styles
[styleSheet parseStyleBlock:@"ul {list-style:disc;} ol {list-style:decimal;}"];
@@ -138,10 +136,9 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
// we cannot skip any characters, NLs turn into spaces and multi-spaces get compressed to singles
NSScanner *scanner = [NSScanner scannerWithString:htmlString];
scanner.charactersToBeSkipped = nil;
- [htmlString release];
// base tag with font defaults
- DTCoreTextFontDescriptor *defaultFontDescriptor = [[[DTCoreTextFontDescriptor alloc] initWithFontAttributes:nil] autorelease];
+ DTCoreTextFontDescriptor *defaultFontDescriptor = [[DTCoreTextFontDescriptor alloc] initWithFontAttributes:nil];
defaultFontDescriptor.pointSize = 12.0 * textScale;
NSString *defaultFontFamily = [options objectForKey:DTDefaultFontFamily];
@@ -215,7 +212,7 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
defaultParagraphStyle.listIndent = [defaultListIndent integerValue];
}
- DTHTMLElement *defaultTag = [[[DTHTMLElement alloc] init] autorelease];
+ DTHTMLElement *defaultTag = [[DTHTMLElement alloc] init];
defaultTag.fontDescriptor = defaultFontDescriptor;
defaultTag.paragraphStyle = defaultParagraphStyle;
defaultTag.textScale = textScale;
@@ -277,7 +274,7 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
{
// make new tag as copy of previous tag
DTHTMLElement *parent = currentTag;
- currentTag = [[currentTag copy] autorelease];
+ currentTag = [currentTag copy];
currentTag.tagName = tagName;
currentTag.textScale = textScale;
currentTag.attributes = tagAttributesDict;
@@ -882,14 +879,14 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
{
NSRange effectiveRange;
- NSMutableDictionary *finalAttributes = [[[tmpString attributesAtIndex:[tmpString length]-1 effectiveRange:&effectiveRange] mutableCopy] autorelease];
- CTParagraphStyleRef style = (CTParagraphStyleRef)[finalAttributes objectForKey:(id)kCTParagraphStyleAttributeName];
+ NSMutableDictionary *finalAttributes = [[tmpString attributesAtIndex:[tmpString length]-1 effectiveRange:&effectiveRange] mutableCopy];
+ CTParagraphStyleRef style = (__bridge CTParagraphStyleRef)[finalAttributes objectForKey:(id)kCTParagraphStyleAttributeName];
DTCoreTextParagraphStyle *paragraphStyle = [DTCoreTextParagraphStyle paragraphStyleWithCTParagraphStyle:style];
paragraphStyle.paragraphSpacing += nextParagraphAdditionalSpaceBefore;
CTParagraphStyleRef newParagraphStyle = [paragraphStyle createCTParagraphStyle];
- [finalAttributes setObject:(id)newParagraphStyle forKey:(id)kCTParagraphStyleAttributeName];
- CFRelease(newParagraphStyle);
+ [finalAttributes setObject:CFBridgingRelease(newParagraphStyle) forKey:(id)kCTParagraphStyleAttributeName];
+ //CFRelease(newParagraphStyle);
[tmpString setAttributes:finalAttributes range:effectiveRange];
@@ -917,7 +914,6 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
// returning the temporary mutable string is faster
//return [self initWithAttributedString:tmpString];
- [self release];
return tmpString;
}
@@ -926,7 +922,7 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib
+ (NSAttributedString *)attributedStringWithHTML:(NSData *)data options:(NSDictionary *)options
{
- NSAttributedString *attrString = [[[NSAttributedString alloc] initWithHTML:data options:options documentAttributes:NULL] autorelease];
+ NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTML:data options:options documentAttributes:NULL];
return attrString;
}
@@ -935,15 +931,15 @@ + (NSAttributedString *)attributedStringWithHTML:(NSData *)data options:(NSDicti
+ (NSAttributedString *)synthesizedSmallCapsAttributedStringWithText:(NSString *)text attributes:(NSDictionary *)attributes
{
- CTFontRef normalFont = (CTFontRef)[attributes objectForKey:(id)kCTFontAttributeName];
+ CTFontRef normalFont = (__bridge CTFontRef)[attributes objectForKey:(id)kCTFontAttributeName];
DTCoreTextFontDescriptor *smallerFontDesc = [DTCoreTextFontDescriptor fontDescriptorForCTFont:normalFont];
smallerFontDesc.pointSize *= 0.7;
CTFontRef smallerFont = [smallerFontDesc newMatchingFont];
NSMutableDictionary *smallAttributes = [attributes mutableCopy];
- [smallAttributes setObject:(id)smallerFont forKey:(id)kCTFontAttributeName];
- CFRelease(smallerFont);
+ [smallAttributes setObject:CFBridgingRelease(smallerFont) forKey:(id)kCTFontAttributeName];
+ //CFRelease(smallerFont);
NSMutableAttributedString *tmpString = [[NSMutableAttributedString alloc] init];
NSScanner *scanner = [NSScanner scannerWithString:text];
@@ -960,20 +956,17 @@ + (NSAttributedString *)synthesizedSmallCapsAttributedStringWithText:(NSString *
part = [part uppercaseString];
NSAttributedString *partString = [[NSAttributedString alloc] initWithString:part attributes:smallAttributes];
[tmpString appendAttributedString:partString];
- [partString release];
}
if ([scanner scanUpToCharactersFromSet:lowerCaseChars intoString:&part])
{
NSAttributedString *partString = [[NSAttributedString alloc] initWithString:part attributes:attributes];
[tmpString appendAttributedString:partString];