DTCoreTextGlyphRun Class Reference
Inherits from | NSObject |
Declared in | DTCoreTextGlyphRun.h |
Overview
This class is an Objective-C wrapper around CTRun
and represents a glyph run. That is, a number of characters from the original NSAttributedString
that share the same characteristics and attributes.
Editor-related extensions to
Tasks
Creating Glyph Runs
Drawing
Getting Information
-
– frameOfGlyphAtIndex:
-
– imageBoundsInContext:
-
– stringRange
-
– stringIndices
-
frame
property -
numberOfGlyphs
property -
attributes
property -
hyperlink
property -
– isTrailingWhitespace
-
ascent
property -
descent
property -
leading
property -
width
property -
writingDirectionIsRightToLeft
property -
attachment
property
DTRichText Methods
Properties
ascent
The ascent (height above the baseline) of the receiver
@property (nonatomic, readonly) CGFloat ascent
Declared In
DTCoreTextGlyphRun.h
attachment
The text attachment of the receiver, or nil
if there is none
@property (nonatomic, readonly) DTTextAttachment *attachment
Declared In
DTCoreTextGlyphRun.h
attributes
The Core Text attributes that are shared by all gylphs of the receiver
@property (nonatomic, readonly) NSDictionary *attributes
Declared In
DTCoreTextGlyphRun.h
descent
The descent (height below the baseline) of the receiver
@property (nonatomic, readonly) CGFloat descent
Declared In
DTCoreTextGlyphRun.h
frame
The frame rectangle of the glyph run, relative to the layout frame coordinate system
@property (nonatomic, readonly) CGRect frame
Declared In
DTCoreTextGlyphRun.h
hyperlink
Returns YES
if the receiver is part of a hyperlink, NO
otherwise
@property (nonatomic, assign, readonly, getter=isHyperlink) BOOL hyperlink
Declared In
DTCoreTextGlyphRun.h
leading
The leading (additional space above the ascent) of the receiver
@property (nonatomic, readonly) CGFloat leading
Declared In
DTCoreTextGlyphRun.h
numberOfGlyphs
The number of glyphs that the receiver is made up of
@property (nonatomic, readonly) NSInteger numberOfGlyphs
Declared In
DTCoreTextGlyphRun.h
Instance Methods
adjustStringRangeToStartAtIndex:
Modifies the internal string range to begin at a given index
- (void)adjustStringRangeToStartAtIndex:(NSInteger)index
Parameters
- index
The new starting string index to set
Discussion
This is needed because due to incremental merging the string indices might change
Declared In
DTRichTextCategories.h
drawDecorationInContext:
Draws the receiver’s decoration into the given context with the position that it derives from the layout line it belongs to. Decoration is background highlighting, underline and strike-through.
- (void)drawDecorationInContext:(CGContextRef)context
Parameters
- context
The graphics context to draw into
Declared In
DTCoreTextGlyphRun.h
drawInContext:
Draws the receiver into the given context with the position that it derives from the layout line it belongs to.
- (void)drawInContext:(CGContextRef)context
Parameters
- context
The graphics context to draw into
See Also
- drawDecorationInContext: for drawing the receiver’s decoration
Declared In
DTCoreTextGlyphRun.h
frameOfGlyphAtIndex:
Determines the frame of a specific glyph
- (CGRect)frameOfGlyphAtIndex:(NSInteger)index
Parameters
- index
The index of the glyph
Return Value
The frame of the glyph
Declared In
DTCoreTextGlyphRun.h
imageBoundsInContext:
The bounds of an image encompassing the entire run.
- (CGRect)imageBoundsInContext:(CGContextRef)context
Parameters
- context
The graphics context used for the measurement
Return Value
The rectangle containing the result
Declared In
DTCoreTextGlyphRun.h
initWithRun:layoutLine:offset:
Creates a new glyph run from a CTRun
, belonging to a given layout line and with a given offset from the left line origin.
- (id)initWithRun:(CTRunRef)run layoutLine:(DTCoreTextLayoutLine *)layoutLine offset:(CGFloat)offset
Parameters
- run
The Core Text glyph run to wrap
- layoutLine
The layout line that this glyph run belongs to
- offset
The offset from the left line origin to place the glyph run at
Return Value
An initialized DTCoreTextGlyphRun
Declared In
DTCoreTextGlyphRun.h
isTrailingWhitespace
Returns YES
if the receiver represents trailing whitespace in a line.
- (BOOL)isTrailingWhitespace
Discussion
This can be used to avoid drawing of background color, strikeout or underline for empty trailing white space glyph runs.
Declared In
DTCoreTextGlyphRun.h
newPathWithGlyphs
Creates a CGPath
containing the shapes of all glyphs in the receiver
- (CGPathRef)newPathWithGlyphs
Declared In
DTCoreTextGlyphRun.h