转载自:http://developer.apple.com/library/mac/#documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/c/func/CTFramesetterSuggestFrameSizeWithConstraints
CTFramesetter Reference
Derived from |
CFType
|
Framework |
ApplicationServices/CoreText
|
Declared in |
CTFramesetter.h
|
Overview
The CTFramesetter opaque type is used to generate text frames. That is, CTFramesetter is an object factory for CTFrame objects.
The framesetter takes an attributed string object and a shape descriptor object and calls into the typesetter to create line objects that fill that shape. The output is a frame object containing an array of lines. The frame can then draw itself directly into the current graphic context.
Functions by Task
Creating a Framesetter
Creating Frames
Frame Sizing
Getting the Type Identifier
Functions
CTFramesetterCreateFrame
Creates an immutable frame using a framesetter.
CTFrameRef CTFramesetterCreateFrame( CTFramesetterRef framesetter, CFRange stringRange, CGPathRef path, CFDictionaryRef frameAttributes );
Parameters
-
framesetter
-
The framesetter used to create the frame.
stringRange
-
The range, of the attributed string that was used to create the framesetter, that is to be typeset in lines fitted into the frame. If the length portion of the range is set to
0
, then the framesetter continues to add lines until it runs out of text or space.
path
-
A CGPath object that specifies the shape of the frame.
frameAttributes
-
Additional attributes that control the frame filling process can be specified here, or
NULL
if there are no such attributes.
Return Value
A reference to a new CTFrame object if the call was successful; otherwise, NULL
.
Discussion
This call creates a frame full of glyphs in the shape of the path provided by the path parameter. The framesetter continues to fill the frame until it either runs out of text or it finds that text no longer fits.
Availability
- Available in OS X v10.5 and later.
Declared In
CTFramesetter.h
CTFramesetterCreateWithAttributedString
Creates an immutable framesetter object from an attributed string.
CTFramesetterRef CTFramesetterCreateWithAttributedString( CFAttributedStringRef string );
Parameters
-
string
-
The attributed string with which to construct the framesetter object.
Return Value
A reference to a CTFramesetter object if the call was successful; otherwise, NULL
.
Discussion
The resultant framesetter object can be used to create and fill text frames with the CTFramesetterCreateFrame
call.
Availability
- Available in OS X v10.5 and later.
Declared In
CTFramesetter.h
CTFramesetterGetTypeID
Returns the Core Foundation type identifier of the framesetter object.
CFTypeID CTFramesetterGetTypeID( void );
Availability
- Available in OS X v10.5 and later.
Declared In
CTFramesetter.h
CTFramesetterGetTypesetter
Returns the typesetter object being used by the framesetter.
CTTypesetterRef CTFramesetterGetTypesetter( CTFramesetterRef framesetter );
Parameters
-
framesetter
-
The framesetter from which a typesetter is requested.
Return Value
A reference to a CTTypesetter object if the call was successful; otherwise, NULL
. The framesetter maintains a reference to the returned object, which should not be released by the caller.
Discussion
Each framesetter uses a typesetter internally to perform line breaking and other contextual analysis based on the characters in a string; this function returns the typesetter being used by a particular framesetter in case the caller would like to perform other operations on that typesetter.
Availability
- Available in OS X v10.5 and later.
Declared In
CTFramesetter.h
CTFramesetterSuggestFrameSizeWithConstraints
Determines the frame size needed for a string range.
CGSize CTFramesetterSuggestFrameSizeWithConstraints( CTFramesetterRef framesetter, CFRange stringRange, CFDictionaryRef frameAttributes, CGSize constraints, CFRange* fitRange );
Parameters
-
framesetter
-
The framesetter used for measuring the frame size.
stringRange
-
The string range to which the frame size applies. The string range is a range over the string used to create the framesetter. If the length portion of the range is set to
0
, then the framesetter continues to add lines until it runs out of text or space.
frameAttributes
-
Additional attributes that control the frame filling process, or
NULL
if there are no such attributes.
constraints
-
The width and height to which the frame size is constrained. A value of
CGFLOAT_MAX
for either dimension indicates that it should be treated as unconstrained.
fitRange
-
On return, contains the range of the string that actually fit in the constrained size.
Return Value
The actual dimensions for the given string range and constraints.
Discussion
This function can be used to determine how much space is needed to display a string, optionally by constraining the space along either dimension.
Availability
- Available in OS X v10.6 and later.
Declared In
CTFramesetter.h
Data Types
CTFramesetterRef
A reference to a Core Foundation framesetter object.
typedef const struct __CTFramesetter *CTFramesetterRef;
Availability
- Available in OS X v10.5 and later.
Declared In
CTFramesetter.h