Skip to content

Commit

Permalink
Added option to glyph run to determine if it is a hyperlink
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Aug 29, 2012
1 parent d86e833 commit 73afbb8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Core/Source/DTCoreTextGlyphRun.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@property (nonatomic, assign, readonly) CGRect frame;
@property (nonatomic, assign, readonly) NSInteger numberOfGlyphs;
@property (nonatomic, unsafe_unretained, readonly) NSDictionary *attributes; // subtle simulator bug - use assign not __unsafe_unretained in 4.2
@property (nonatomic, assign, readonly, getter=isHyperlink) BOOL hyperlink;

@property (nonatomic, assign, readonly) CGFloat ascent;
@property (nonatomic, assign, readonly) CGFloat descent;
Expand Down
19 changes: 18 additions & 1 deletion Core/Source/DTCoreTextGlyphRun.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ @implementation DTCoreTextGlyphRun
NSArray *stringIndices;

DTTextAttachment *_attachment;
BOOL _hyperlink;

BOOL _didCheckForAttachmentInAttributes;
BOOL _didCheckForHyperlinkInAttributes;
BOOL _didCalculateMetrics;
}

Expand Down Expand Up @@ -246,6 +249,21 @@ - (DTTextAttachment *)attachment
return _attachment;
}

- (BOOL)isHyperlink
{
if (!_hyperlink)
{
if (!_didCheckForHyperlinkInAttributes)
{
_hyperlink = [self.attributes objectForKey:DTLinkAttribute]!=nil;

_didCheckForHyperlinkInAttributes = YES;
}
}

return _hyperlink;
}

- (CGRect)frame
{
if (!_didCalculateMetrics)
Expand Down Expand Up @@ -296,7 +314,6 @@ - (CGFloat)leading
return leading;
}


@synthesize frame = _frame;
@synthesize numberOfGlyphs;
@synthesize attributes;
Expand Down

0 comments on commit 73afbb8

Please sign in to comment.