Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added option to glyph run to determine if it is a hyperlink

  • Loading branch information...
commit 73afbb85a6fd77e56ddea11e0422211470189743 1 parent d86e833
@Cocoanetics authored
View
1  Core/Source/DTCoreTextGlyphRun.h
@@ -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;
View
19 Core/Source/DTCoreTextGlyphRun.m
@@ -49,7 +49,10 @@ @implementation DTCoreTextGlyphRun
NSArray *stringIndices;
DTTextAttachment *_attachment;
+ BOOL _hyperlink;
+
BOOL _didCheckForAttachmentInAttributes;
+ BOOL _didCheckForHyperlinkInAttributes;
BOOL _didCalculateMetrics;
}
@@ -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)
@@ -296,7 +314,6 @@ - (CGFloat)leading
return leading;
}
-
@synthesize frame = _frame;
@synthesize numberOfGlyphs;
@synthesize attributes;
Please sign in to comment.
Something went wrong with that request. Please try again.