Mac Developer Library

Developer

ApplicationServices Framework Reference CTFramesetter Reference

Options
Deployment Target:

On This Page
Language:

CTFramesetter Reference

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

  • Creates an immutable framesetter object from an attributed string.

    Declaration

    Swift

    func CTFramesetterCreateWithAttributedString(_ string: CFAttributedString!) -> CTFramesetter!

    Objective-C

    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.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Creates an immutable frame using a framesetter.

    Declaration

    Swift

    func CTFramesetterCreateFrame(_ framesetter: CTFramesetter!, _ stringRange: CFRange, _ path: CGPath!, _ frameAttributes: CFDictionary!) -> CTFrame!

    Objective-C

    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. The path may be non-rectangular in versions of OS X v10.7 or later and versions of iOS 4.2 or later.

    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.

    Special Considerations

    In versions of OS X prior to 10.7 and versions of iOS prior to 4.2, this function returns NULL if the CGPath specified by the path parameter is not rectangular.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the typesetter object being used by the framesetter.

    Declaration

    Swift

    func CTFramesetterGetTypesetter(_ framesetter: CTFramesetter!) -> CTTypesetter!

    Objective-C

    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.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Determines the frame size needed for a string range.

    Declaration

    Swift

    func CTFramesetterSuggestFrameSizeWithConstraints(_ framesetter: CTFramesetter!, _ stringRange: CFRange, _ frameAttributes: CFDictionary!, _ constraints: CGSize, _ fitRange: UnsafeMutablePointer<CFRange>) -> CGSize

    Objective-C

    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.

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

  • Returns the Core Foundation type identifier of the framesetter object.

    Declaration

    Swift

    func CTFramesetterGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CTFramesetterGetTypeID ( void );

    Import Statement

    Objective-C

    @import CoreText;

    Swift

    import CoreText

    Availability

    Available in OS X v10.5 and later.

Data Types

  • A reference to a Core Foundation framesetter object.

    Declaration

    Swift

    typealias CTFramesetterRef = CTFramesetter

    Objective-C

    typedef const struct __CTFramesetter *CTFramesetterRef;

    Availability

    Available in OS X v10.5 and later.