| Derived from | CFType |
| Framework | ApplicationServices/CoreText |
| Declared in | CTRun.h |
The CTRun opaque type represents a glyph run, which is a set of consecutive glyphs sharing the same attributes and direction.
The typesetter creates glyph runs as it produces lines from character strings, attributes, and font objects. That is, a line is constructed of one or more glyphs runs. Glyph runs can draw themselves into a graphic context, if desired, although most users have no need to interact directly with glyph runs.
CTRunGetGlyphCount
CTRunGetAttributes
CTRunGetStatus
CTRunGetGlyphsPtr
CTRunGetGlyphs
CTRunGetPositionsPtr
CTRunGetPositions
CTRunGetStringIndicesPtr
CTRunGetStringIndices
CTRunGetStringRange
Draws a complete run or part of one.
void CTRunDraw( CTRunRef run, CGContextRef context, CFRange range );
The run to draw.
The context into which to draw the run.
The portion of the run to draw. If the length of the range is set to 0, then the draw operation continues from the start index of the range to the end of the run.
This is a convenience call, because the run could be drawn by accessing the glyphs. This call can leave the graphics context in any state and does not flush the context after the draw operation.
CTRun.hReturns the attribute dictionary that was used to create the glyph run.
CFDictionaryRef CTRunGetAttributes( CTRunRef run );
The run for which to return attributes.
A valid CFDictionaryRef or NULL on error or if the run has no attributes.
The dictionary returned is either the same one that was set as an attribute dictionary on the original attributed string or a dictionary that has been manufactured by the layout engine. Attribute dictionaries can be manufactured in the case of font substitution or if the run is missing critical attributes.
CTRun.hGets the glyph count for the run.
CFIndex CTRunGetGlyphCount( CTRunRef run );
The run for which to return the glyph count.
The number of glyphs that the run contains, or if there are no glyphs in this run, a value of 0.
CTRun.hCopies a range of glyphs into a user-provided buffer.
void CTRunGetGlyphs( CTRunRef run, CFRange range, CGGlyph* buffer );
The run from which to copy glyphs.
The range of glyphs to copy. If the length of the range is set to 0, then the copy operation continues from the range's start index to the end of the run.
The buffer the glyphs are copied to. The buffer must be allocated to at least the value specified by the range's length.
CTRun.hReturns a direct pointer for the glyph array stored in the run.
const CGGlyph* CTRunGetGlyphsPtr( CTRunRef run );
The run from which to return glyphs.
A valid pointer to an array of CGGlyph structures, or NULL.
The glyph array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. If this function returns NULL, the caller must allocate its own buffer and call CTRunGetGlyphs to fetch the glyphs.
CTRun.hCalculates the image bounds for a glyph range.
CGRect CTRunGetImageBounds( CTRunRef run, CGContextRef context, CFRange range );
The run for which to calculate the image bounds.
The context for the image bounds being calculated. This is required because the context could have settings in it that would cause changes in the image bounds.
The portion of the run to measure. If the length of the range is set to 0, then the measure operation continues from the start index of the range to the end of the run.
A rectangle that tightly encloses the paths of the run's glyphs, or, if run, context, or range is invalid, CGRectNull.
CTRun.hCopies a range of glyph positions into a user-provided buffer.
void CTRunGetPositions( CTRunRef run, CFRange range, CGPoint* buffer );
The run from which to copy glyph positions.
The range of glyph positions to copy. If the length of the range is set to 0, then the copy operation will continue from the start index of the range to the end of the run.
The buffer to which the glyph positions are copied. The buffer must be allocated to at least the value specified by the range's length.
CTRun.hReturns a direct pointer for the glyph position array stored in the run.
const CGPoint* CTRunGetPositionsPtr( CTRunRef run );
The run from which to access glyph positions.
A valid pointer to an array of CGPoint structures, or NULL.
The glyph positions in a run are relative to the origin of the line containing the run. The position array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. If this function returns NULL, the caller must allocate its own buffer and call CTRunGetPositions to fetch the glyph positions.
CTRun.hReturns the run's status.
CTRunStatus CTRunGetStatus( CTRunRef run );
The run for which to return the status.
The run's status.
Runs have status that can be used to expedite certain operations. Knowing the direction and ordering of a run's glyphs can aid in string index analysis, whereas knowing whether the positions reference the identity text matrix can avoid expensive comparisons. This status is provided as a convenience, because this information is not strictly necessary but can be helpful in some circumstances.
CTRun.hCopies a range of string indices into a user-provided buffer.
void CTRunGetStringIndices( CTRunRef run, CFRange range, CFIndex* buffer );
The run from which to copy the string indices.
The range of string indices to copy. If the length of the range is set to 0, then the copy operation continues from the range's start index to the end of the run.
The buffer to which the string indices are copied. The buffer must be allocated to at least the value specified by the range's length.
The indices are the character indices that originally spawned the glyphs that make up the run. They can be used to map the glyphs in the run back to the characters in the backing store.
CTRun.hReturns a direct pointer for the string indices stored in the run.
const CFIndex* CTRunGetStringIndicesPtr( CTRunRef run );
The run for which to return string indices.
A valid pointer to an array of CFIndex structures, or NULL.
The indices are the character indices that originally spawned the glyphs that make up the run. They can be used to map the glyphs in the run back to the characters in the backing store. The string indices array will have a length equal to the value returned by CTRunGetGlyphCount. The caller should be prepared for this function to return NULL even if there are glyphs in the stream. If this function returns NULL, the caller must allocate its own buffer and call CTRunGetStringIndices to fetch the indices.
CTRun.hGets the range of characters that originally spawned the glyphs in the run.
CFRange CTRunGetStringRange( CTRunRef run );
The run for which to access the string range.
The range of characters that originally spawned the glyphs, of if run is invalid, an empty range.
CTRun.hReturns the text matrix needed to draw this run.
CGAffineTransform CTRunGetTextMatrix( CTRunRef run );
The run object from which to get the text matrix.
A CGAffineTransform structure.
To properly draw the glyphs in a run, the fields tx and ty of the CGAffineTransform returned by this function should be set to the current text position.
CTRun.hReturns the Core Foundation type identifier of the run object.
CFTypeID CTRunGetTypeID( void );
CTRun.hGets the typographic bounds of the run.
double CTRunGetTypographicBounds( CTRunRef run, CFRange range, CGFloat* ascent, CGFloat* descent, CGFloat* leading );
The run for which to calculate the typographic bounds.
The portion of the run to measure. If the length of the range is set to 0, then the measure operation continues from the range's start index to the end of the run.
On output, the ascent of the run. This can be set to NULL if not needed.
On output, the descent of the run. This can be set to NULL if not needed.
On output, the leading of the run. This can be set to NULL if not needed.
The typographic width of the run, or if run or range is invalid, 0.
CTRun.hA reference to a run object.
typedef const struct __CTRun *CTRunRef;
CTRun.hA bitfield passed back by the CTRunGetStatus function that is used to indicate the disposition of the run.
enum{
kCTRunStatusNoStatus = 0,
kCTRunStatusRightToLeft = (1 << 0),
kCTRunStatusNonMonotonic = (1 << 1),
kCTRunStatusHasNonIdentityMatrix = (1 << 2)
};
typedef uint32_t CTRunStatus;
kCTRunStatusNoStatusThe run has no special attributes.
Available in Mac OS X v10.5 and later.
Declared in CTRun.h
kCTRunStatusRightToLeftThe run proceeds from right to left.
Available in Mac OS X v10.5 and later.
Declared in CTRun.h
kCTRunStatusNonMonotonicThe run has been reordered in some way such that the string indices associated with the glyphs are no longer strictly increasing (for left-to-right runs) or decreasing (for right-to-left runs).
Available in Mac OS X v10.5 and later.
Declared in CTRun.h
kCTRunStatusHasNonIdentityMatrixThe run requires a specific text matrix to be set in the current Core Graphics context for proper drawing.
Available in Mac OS X v10.5 and later.
Declared in CTRun.h
CTRun.h
Last updated: 2007-05-24