Mac Developer Library

Developer

AppKit Framework Reference NSLayoutManager Class Reference

Options
Deployment Target:

On This Page
Language:

NSLayoutManager

Inheritance


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

An NSLayoutManager object coordinates the layout and display of characters held in an NSTextStorage object. It maps Unicode character codes to glyphs, sets the glyphs in a series of NSTextContainer objects, and displays them in a series of NSTextView objects. In addition to its core function of laying out text, an NSLayoutManager object coordinates its NSTextView objects, provides services to those text views to support NSRulerView instances for editing paragraph styles, and handles the layout and display of text attributes not inherent in glyphs (such as underline or strikethrough). You can create a subclass of NSLayoutManager to handle additional text attributes, whether inherent or not.

Text Antialiasing

NSLayoutManager provides the threshold for text antialiasing. It looks at the AppleAntiAliasingThreshold default value. If the font size is smaller than or equal to this threshold size, the text is rendered aliased by NSLayoutManager. You can change the threshold value from the Appearance pane of System Preferences.

Thread Safety of NSLayoutManager

Generally speaking, a given layout manager (and associated objects) should not be used in more than one block, operation, or thread at a time. Most layout managers are used on the main thread, since it is the main thread on which their text views are displayed, and since background layout occurs on the main thread.

If you want to use a layout manager on a background thread, first make sure that text views associated with that layout manager (if any) are not displayed while the layout manager is being used on the background thread, and, second, turn off background layout for that layout manager while it is being used on the background thread. The most effective way to ensure that no text view is displayed, without knowing deep implementation, is just not to connect a text view to the layout manager.

Noncontiguous Layout

Noncontiguous layout is an optional layout manager behavior new in OS X v10.5. Previously, both glyph generation and layout were always performed, in order, from the beginning to the end of the document. When noncontiguous layout is turned on, however, the layout manager gains the option of performing glyph generation or layout for one portion of the document without having done so for previous sections. This can provide significant performance improvements for large documents.

Noncontiguous layout is not turned on automatically because direct clients of NSLayoutManager typically have relied on the previous behavior—for example, by forcing layout for a given glyph range, and then assuming that previous glyphs would therefore be laid out. Clients who use NSLayoutManager only indirectly—for example, those who use NSTextView without directly calling the underlying layout manager—can usually turn on noncontiguous layout without difficulty. Clients using NSLayoutManager directly need to examine their usage before turning on noncontiguous layout.

To turn on noncontiguous layout, use setAllowsNonContiguousLayout:. In addition, see the other methods in Managing Noncontiguous Layout, many of which enable you to ensure that glyph generation and layout are performed for specified portions of the text. The behavior of a number of other layout manager methods is affected by the state of noncontiguous layout, as noted in the discussion sections of those method descriptions.

  • init() - init Designated Initializer

    Initializes the receiver, a newly created NSLayoutManager object.

    Declaration

    Swift

    init()

    Objective-C

    - (instancetype)init

    Discussion

    This method is the designated initializer for the NSLayoutManager class. Returns an initialized object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    addLayoutManager: (NSTextStorage)
    – addTextContainer:

  • Sets the receiver’s NSTextStorage object.

    Declaration

    Swift

    unowned(unsafe) var textStorage: NSTextStorage?

    Objective-C

    @property(assign) NSTextStorage *textStorage

    Parameters

    textStorage

    The text storage object to set.

    Discussion

    This method is invoked automatically when you add an NSLayoutManager to an NSTextStorage object; you should never need to invoke it directly, but you might want to override it. If you want to replace the NSTextStorage object for an established group of text-system objects containing the receiver, use replaceTextStorage:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    addLayoutManager: (NSTextStorage)

  • Returns the receiver’s text storage object.

    Declaration

    Swift

    unowned(unsafe) var textStorage: NSTextStorage?

    Objective-C

    @property(assign) NSTextStorage *textStorage

    Return Value

    The receiver’s text storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the text storage object from which the NSGlyphGenerator object procures characters for glyph generation.

    Declaration

    Swift

    var attributedString: NSAttributedString? { get }

    Objective-C

    @property(readonly, strong) NSAttributedString *attributedString

    Return Value

    The receiver’s text storage object.

    Discussion

    This method is part of the NSGlyphStorage protocol, for use by the glyph generator. For NSLayoutManager the attributed string is equivalent to the text storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Replaces the NSTextStorage object for the group of text-system objects containing the receiver with the given text storage object.

    Declaration

    Swift

    func replaceTextStorage(_ newTextStorage: NSTextStorage)

    Objective-C

    - (void)replaceTextStorage:(NSTextStorage *)newTextStorage

    Parameters

    newTextStorage

    The text storage object to set.

    Discussion

    All NSLayoutManager objects sharing the original NSTextStorage object then share the new one. This method makes all the adjustments necessary to keep these relationships intact, unlike setTextStorage:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the glyph generator used by this layout manager.

    Declaration

    Swift

    var glyphGenerator: NSGlyphGenerator!

    Objective-C

    @property(strong) NSGlyphGenerator *glyphGenerator

    Parameters

    glyphGenerator

    The new glyph generator to set.

    Discussion

    Setting the glyph generator invalidates all glyphs and layout in the layout manager.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the glyph generator used by this layout manager.

    Declaration

    Swift

    var glyphGenerator: NSGlyphGenerator!

    Objective-C

    @property(strong) NSGlyphGenerator *glyphGenerator

    Return Value

    The glyph generator.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Invalidates the cached glyphs for the characters in the given character range, adjusts the character indices of all the subsequent glyphs by the change in length, and invalidates the new character range.

    Declaration

    Swift

    func invalidateGlyphsForCharacterRange(_ charRange: NSRange, changeInLength lengthChange: Int, actualCharacterRange actualCharRange: NSRangePointer)

    Objective-C

    - (void)invalidateGlyphsForCharacterRange:(NSRange)charRange changeInLength:(NSInteger)lengthChange actualCharacterRange:(NSRangePointer)actualCharRange

    Parameters

    charRange

    The range of characters for which to invalidate glyphs.

    lengthChange

    The number of characters added or removed.

    actualCharRange

    If not NULL, on output, the actual range invalidated after any necessary expansion. This range can be larger than the range of characters given due to the effect of context on glyphs and layout.

    Discussion

    This method only invalidates glyph information and performs no glyph generation or layout. Because invalidating glyphs also invalidates layout, after invoking this method you should also invoke invalidateLayoutForCharacterRange:actualCharacterRange:, passing charRange as the first argument.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies explicitly when portions of the glyph stream depend on layout.

    Declaration

    Swift

    func invalidateGlyphsOnLayoutInvalidationForGlyphRange(_ glyphRange: NSRange)

    Objective-C

    - (void)invalidateGlyphsOnLayoutInvalidationForGlyphRange:(NSRange)glyphRange

    Parameters

    glyphRange

    The range of glyphs to invalidate.

    Discussion

    This method is for the use of the typesetter, to allow it to specify explicitly when portions of the glyph stream depend on layout, for example, because they have had hyphens inserted. Therefore, the glyphs are invalidated the next time their layout is invalidated, so that they will be regenerated before being laid out again.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Invalidates the layout information for the glyphs mapped to the given range of characters.

    Declaration

    Swift

    func invalidateLayoutForCharacterRange(_ charRange: NSRange, isSoft flag: Bool, actualCharacterRange actualCharRange: NSRangePointer)

    Objective-C

    - (void)invalidateLayoutForCharacterRange:(NSRange)charRange isSoft:(BOOL)flag actualCharacterRange:(NSRangePointer)actualCharRange

    Parameters

    charRange

    The character range for which glyphs are invalidated.

    flag

    If YEStrue, invalidates internal caches in the layout manager; if NOfalse, invalidates layout. See the discussion section.

    actualCharRange

    If not NULL, on output, the range of characters mapped to the glyphs whose layout information is invalidated. This range can be larger than the range of characters given due to the effect of context on glyphs and layout.

    Discussion

    This method only invalidates information; it performs no glyph generation or layout. You should rarely need to invoke this method.

    For code that needs to work on both OS X v10.5 and previous releases, the following procedures should be used. For OS X v10.4 and before, invalidation should consist of

    1. Calling this method with the flag set to YEStrue, for the range that has actually become invalid.

    2. Calling this method with the flag set to NOfalse, for the range (if any) that follows that range, usually extending to the end of the text, that might need to be moved due to relayout of the invalidated range.

    As of OS X v10.5, the semantics of the flag parameter are slightly different. Soft layout holes are obsolete in OS X v10.5 and later, so the flag is no longer necessary. If the method is called with flag set to NOfalse, then it has the effect of invalidating layout. If it's called with the flag set to YEStrue, then it does not actually invalidate layout; it invalidates a number of internal caches, but otherwise has no effect, and in general is unnecessary.

    This method is superseded by invalidateLayoutForCharacterRange:actualCharacterRange: and will be deprecated in a future release.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Invalidates the layout information for the glyphs mapped to the given range of characters.

    Declaration

    Swift

    func invalidateLayoutForCharacterRange(_ charRange: NSRange, actualCharacterRange actualCharRange: NSRangePointer)

    Objective-C

    - (void)invalidateLayoutForCharacterRange:(NSRange)charRange actualCharacterRange:(NSRangePointer)actualCharRange

    Parameters

    charRange

    The range of characters to invalidate.

    actualCharRange

    If not NULL, on output, the actual range invalidated after any necessary expansion.

    Discussion

    This method has the same effect as invalidateLayoutForCharacterRange:isSoft:actualCharacterRange: with flag set to NOfalse.

    This method only invalidates information; it performs no glyph generation or layout. You should rarely need to invoke this method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Invalidates display for the given character range.

    Declaration

    Swift

    func invalidateDisplayForCharacterRange(_ charRange: NSRange)

    Objective-C

    - (void)invalidateDisplayForCharacterRange:(NSRange)charRange

    Parameters

    charRange

    The character range for which display is invalidated.

    Discussion

    Parts of the range that are not laid out are remembered and redisplayed later when the layout is available. Does not actually cause layout.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Marks the glyphs in the given glyph range as needing display, as well as the appropriate regions of the NSTextView objects that display those glyphs (using the NSView method setNeedsDisplayInRect:).

    Declaration

    Swift

    func invalidateDisplayForGlyphRange(_ glyphRange: NSRange)

    Objective-C

    - (void)invalidateDisplayForGlyphRange:(NSRange)glyphRange

    Parameters

    glyphRange

    The range of glyphs to invalidate.

    Discussion

    You should rarely need to invoke this method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Invalidates the layout information, and possibly glyphs, for the given text container and all subsequent NSTextContainer objects.

    Declaration

    Swift

    func textContainerChangedGeometry(_ aTextContainer: NSTextContainer)

    Objective-C

    - (void)textContainerChangedGeometry:(NSTextContainer *)aTextContainer

    Parameters

    aTextContainer

    The text container whose layout is invalidated.

    Discussion

    This method is invoked automatically by other components of the text system; you should rarely need to invoke it directly. Subclasses of NSTextContainer, however, must invoke this method any time their size of shape changes (a text container that dynamically adjusts its shape to wrap text around placed graphics, for example, must do so when a graphic is added, moved, or removed).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Updates information needed to manage NSTextView objects in the given text container.

    Declaration

    Swift

    func textContainerChangedTextView(_ aTextContainer: NSTextContainer)

    Objective-C

    - (void)textContainerChangedTextView:(NSTextContainer *)aTextContainer

    Parameters

    aTextContainer

    The text container whose text view has changed.

    Discussion

    This method is called by a text container, whenever its text view changes, to keep notifications synchronized. You should rarely need to invoke it directly.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Invalidates glyph and layout information for a portion of the text in the given text storage object.

    Declaration

    Swift

    func textStorage(_ aTextStorage: NSTextStorage, edited mask: NSTextStorageEditedOptions, range newCharRange: NSRange, changeInLength delta: Int, invalidatedRange invalidatedCharRange: NSRange)

    Objective-C

    - (void)textStorage:(NSTextStorage *)aTextStorage edited:(NSTextStorageEditedOptions)mask range:(NSRange)newCharRange changeInLength:(NSInteger)delta invalidatedRange:(NSRange)invalidatedCharRange

    Parameters

    aTextStorage

    The text storage whose information is invalidated.

    mask

    Specifies the nature of the changes. Its value is made by combining with the C bitwise OR operator the constants described in “Change notifications” in NSTextStorage (NSTextStorageEditedAttributes and NSTextStorageEditedCharacters).

    newCharRange

    Indicates the extent of characters resulting from the edits.

    delta

    If the NSTextStorageEditedCharacters bit of mask is set, gives the number of characters added to or removed from the original range (otherwise its value is irrelevant).

    invalidatedCharRange

    Represents the range of characters affected after attributes have been fixed. Is either equal to newCharRange or larger. For example, deleting a paragraph separator character invalidates the layout information for all characters in the paragraphs that precede and follow the separator.

    Discussion

    This message is sent from the NSTextStorageobject’s processEditing method to indicate that its characters or attributes have changed. This method invalidates glyphs and layout for the affected characters.

    For example, after replacing “The” with “Several” to produce the string “Several files couldn’t be saved”, newCharRange is {0, 7} and delta is 4. The receiver uses this information to update its character-to-glyph mapping and to update the selection range based on the change.

    The textStorage:edited:range:changeInLength:invalidatedRange: messages are sent in a series to each NSLayoutManager object associated with the text storage object, so the layout managers receiving them shouldn’t edit aTextStorage while this method is executing. If one of them does, the newCharRange, delta, and invalidatedCharRange arguments are incorrect for all following layout managers that receive the message.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether the receiver generates glyphs and lays them out when the application’s run loop is idle.

    Declaration

    Swift

    var backgroundLayoutEnabled: Bool

    Objective-C

    @property BOOL backgroundLayoutEnabled

    Parameters

    flag

    If YEStrue, background layout is enabled; if NOfalse, the receiver performs glyph generation and layout only when necessary.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the receiver generates glyphs and lays out text when the application’s run loop is idle.

    Declaration

    Swift

    var backgroundLayoutEnabled: Bool

    Objective-C

    @property BOOL backgroundLayoutEnabled

    Return Value

    YEStrue if the receiver generates glyphs and lays out text when the application’s run loop is idle, NOfalse if it performs glyph generation and layout only when necessary.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Inserts a single glyph into the glyph stream at the given index and maps it to the character at the given character index.

    Declaration

    Swift

    func insertGlyph(_ glyph: NSGlyph, atGlyphIndex glyphIndex: Int, characterIndex charIndex: Int)

    Objective-C

    - (void)insertGlyph:(NSGlyph)glyph atGlyphIndex:(NSUInteger)glyphIndex characterIndex:(NSUInteger)charIndex

    Parameters

    glyph

    The glyph to insert.

    glyphIndex

    The index at which to insert the glyph.

    charIndex

    The index of the character to which the glyph is mapped.

    Discussion

    If the glyph is mapped to several characters, charIndex should indicate the first character it’s mapped to.

    This method is for use by the glyph-generation mechanism and doesn’t perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Inserts the given glyphs into the glyph cache at the given index and maps them to characters beginning at the given character index.

    Declaration

    Swift

    func insertGlyphs(_ glyphs: UnsafePointer<NSGlyph>, length glyphIndex: Int, forStartingGlyphAtIndex length: Int, characterIndex charIndex: Int)

    Objective-C

    - (void)insertGlyphs:(const NSGlyph *)glyphs length:(NSUInteger)glyphIndex forStartingGlyphAtIndex:(NSUInteger)length characterIndex:(NSUInteger)charIndex

    Parameters

    glyphs

    The glyphs to insert.

    glyphIndex

    The index in the glyph cache to begin inserting glyphs.

    length

    The number of glyphs to insert.

    charIndex

    Index of first character to be mapped.

    Discussion

    This method is part of the NSGlyphStorage protocol, for use by the glyph generator. It enables bulk insertion of glyphs into the glyph cache.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Indicates whether the specified index refers to a valid glyph, otherwise NOfalse.

    Declaration

    Swift

    func isValidGlyphIndex(_ glyphIndex: Int) -> Bool

    Objective-C

    - (BOOL)isValidGlyphIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    The index of a glyph in the receiver.

    Return Value

    YEStrue if the specified glyphIndex refers to a valid glyph, otherwise NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the glyph at glyphIndex.

    Declaration

    Swift

    func glyphAtIndex(_ glyphIndex: Int) -> NSGlyph

    Objective-C

    - (NSGlyph)glyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    The index of a glyph in the receiver. This value must not exceed the bounds of the receiver’s glyph array.

    Return Value

    The glyph at glyphIndex.

    Discussion

    Raises an NSRangeException if glyphIndex is out of bounds.

    Performs glyph generation if needed. To avoid an exception with glyphAtIndex: you must first check the glyph index against the number of glyphs, which requires generating all glyphs. Another method, glyphAtIndex:isValidIndex:, generates glyphs only up to the one requested, so using it can be more efficient.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • If the given index is valid, returns the glyph at that location and optionally returns a flag indicating whether the requested index is in range.

    Declaration

    Swift

    func glyphAtIndex(_ glyphIndex: Int, isValidIndex isValidIndex: UnsafeMutablePointer<ObjCBool>) -> NSGlyph

    Objective-C

    - (NSGlyph)glyphAtIndex:(NSUInteger)glyphIndex isValidIndex:(BOOL *)isValidIndex

    Parameters

    glyphIndex

    The index of the glyph to be returned.

    isValidIndex

    If not NULL, on output, YEStrue if the requested index is in range; otherwise NOfalse.

    Return Value

    The glyph at the requested index, or NSNullGlyph if the requested index is out of the range {0, numberOfGlyphs}.

    Discussion

    If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including glyphIndex.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Replaces the glyph at the given index with a new glyph.

    Declaration

    Swift

    func replaceGlyphAtIndex(_ glyphIndex: Int, withGlyph newGlyph: NSGlyph)

    Objective-C

    - (void)replaceGlyphAtIndex:(NSUInteger)glyphIndex withGlyph:(NSGlyph)newGlyph

    Parameters

    glyphIndex

    Index of the glyph to replace.

    newGlyph

    The new glyph.

    Discussion

    Doesn’t alter the glyph-to-character mapping or invalidate layout information. The character index of the glyph is assumed to remain the same (although it can, of course, be set explicitly if needed).

    This method is for use by the glyph-generation mechanism and doesn’t perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Fills the passed-in buffer with a sequence of glyphs

    Declaration

    Swift

    func getGlyphs(_ glyphArray: UnsafeMutablePointer<NSGlyph>, range glyphRange: NSRange) -> Int

    Objective-C

    - (NSUInteger)getGlyphs:(NSGlyph *)glyphArray range:(NSRange)glyphRange

    Parameters

    glyphArray

    On output, the displayable glyphs from glyphRange, null-terminated. Does not include in the result any NSNullGlyph or other glyphs that are not shown. The memory passed in should be large enough for at least glyphRange.length+1 elements.

    glyphRange

    The range of glyphs from which to return the displayable glyphs.

    Return Value

    The actual number of glyphs filled into the array is returned (not counting the null-termination).

    Discussion

    Raises an NSRangeException if the range specified exceeds the bounds of the actual glyph range for the receiver. Performs glyph generation if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the glyphs and information needed to perform layout for the given glyph range.

    Declaration

    Swift

    func getGlyphsInRange(_ glyphRange: NSRange, glyphs glyphBuffer: UnsafeMutablePointer<NSGlyph>, characterIndexes charIndexBuffer: UnsafeMutablePointer<Int>, glyphInscriptions inscribeBuffer: UnsafeMutablePointer<NSGlyphInscription>, elasticBits elasticBuffer: UnsafeMutablePointer<ObjCBool>) -> Int

    Objective-C

    - (NSUInteger)getGlyphsInRange:(NSRange)glyphRange glyphs:(NSGlyph *)glyphBuffer characterIndexes:(NSUInteger *)charIndexBuffer glyphInscriptions:(NSGlyphInscription *)inscribeBuffer elasticBits:(BOOL *)elasticBuffer

    Discussion

    This is a convenience method for getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels: that does not return a bidiLevelBuffer.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the glyphs and information needed to perform layout for the given glyph range.

    Declaration

    Swift

    func getGlyphsInRange(_ glyphRange: NSRange, glyphs glyphBuffer: UnsafeMutablePointer<NSGlyph>, characterIndexes charIndexBuffer: UnsafeMutablePointer<Int>, glyphInscriptions inscribeBuffer: UnsafeMutablePointer<NSGlyphInscription>, elasticBits elasticBuffer: UnsafeMutablePointer<ObjCBool>, bidiLevels bidiLevelBuffer: UnsafeMutablePointer<UInt8>) -> Int

    Objective-C

    - (NSUInteger)getGlyphsInRange:(NSRange)glyphRange glyphs:(NSGlyph *)glyphBuffer characterIndexes:(NSUInteger *)charIndexBuffer glyphInscriptions:(NSGlyphInscription *)inscribeBuffer elasticBits:(BOOL *)elasticBuffer bidiLevels:(unsigned char *)bidiLevelBuffer

    Parameters

    glyphRange

    The range of glyphs to lay out.

    glyphBuffer

    On output, the sequence of glyphs needed to lay out the given glyph range.

    charIndexBuffer

    On output, the indexes of the original characters corresponding to the given glyph range. Note that a glyph at index 1 is not necessarily mapped to the character at index 1, since a glyph may be for a ligature or accent.

    inscribeBuffer

    On output, the inscription attributes for each glyph, which are used to lay out characters that are combined together. The possible values are described in Constants.

    elasticBuffer

    On output, values indicating whether a glyph is elastic for each glyph. An elastic glyph can be made longer at the end of a line or when needed for justification.

    bidiLevelBuffer

    On output, the direction of each glyph for bidirectional text. The values range from 0 to 61 as defined by Unicode Standard Annex #9. An even value means the glyph goes left-to-right, and an odd value means the glyph goes right-to-left.

    Return Value

    The number of glyphs returned in glyphBuffer.

    Discussion

    This method and getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits: are intended primarily to enable the typesetter to obtain in bulk the glyphs and other information that it needs to perform layout. These methods return all glyphs in the range, including NSNullGlyph and not-shown glyphs. They do not null-terminate the results. Each pointer passed in should either be NULL, or else point to sufficient memory to hold glyphRange.length elements.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Deletes the glyphs in the given range from the receiver’s glyph store.

    Declaration

    Swift

    func deleteGlyphsInRange(_ glyphRange: NSRange)

    Objective-C

    - (void)deleteGlyphsInRange:(NSRange)glyphRange

    Parameters

    glyphRange

    The range of glyphs to delete.

    Discussion

    This method is for use by the glyph-generation mechanism and doesn’t perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the number of glyphs in the receiver.

    Declaration

    Swift

    var numberOfGlyphs: Int { get }

    Objective-C

    @property(readonly) NSUInteger numberOfGlyphs

    Return Value

    The number of glyphs.

    Discussion

    If noncontiguous layout is not enabled, this method forces generation of glyphs for all characters.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the index of the character corresponding to the glyph at the given glyph index.

    Declaration

    Swift

    func setCharacterIndex(_ charIndex: Int, forGlyphAtIndex glyphIndex: Int)

    Objective-C

    - (void)setCharacterIndex:(NSUInteger)charIndex forGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    charIndex

    The index to set.

    glyphIndex

    The glyph corresponding to the character whose index is set. The glyph must already be present.

    Discussion

    This method is for use by the glyph-generation mechanism and doesn’t perform any invalidation or generation of the glyphs or layout. This method should be invoked only during glyph generation and typesetting, in almost all cases only by the glyph generator or typesetter. For example, a custom glyph generator or typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the index in the text storage for the first character associated with the given glyph.

    Declaration

    Swift

    func characterIndexForGlyphAtIndex(_ glyphIndex: Int) -> Int

    Objective-C

    - (NSUInteger)characterIndexForGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    The index of the glyph for which to return the associated character.

    Return Value

    The index of the first character associated with the glyph at the specified index.

    Discussion

    If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including glyphIndex. This method accepts an index beyond the last glyph, returning an index extrapolated from the last actual glyph index.

    In many cases it’s better to use the range-mapping methods, characterRangeForGlyphRange:actualGlyphRange: and glyphRangeForCharacterRange:actualCharacterRange:, which provide more comprehensive information.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the index of the first glyph associated with the character at the specified index.

    Declaration

    Swift

    func glyphIndexForCharacterAtIndex(_ charIndex: Int) -> Int

    Objective-C

    - (NSUInteger)glyphIndexForCharacterAtIndex:(NSUInteger)charIndex

    Parameters

    charIndex

    The index of the character for which to return the associated glyph.

    Return Value

    The index of the first glyph associated with the character at the specified index.

    Discussion

    If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including those associated with the specified character. This method accepts an index beyond the last character, returning an index extrapolated from the last actual character index.

    In many cases it’s better to use the range-mapping methods, characterRangeForGlyphRange:actualGlyphRange: and glyphRangeForCharacterRange:actualCharacterRange:, which provide more comprehensive information.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the range of characters that generated the glyphs in the given glyph range.

    Declaration

    Swift

    func characterRangeForGlyphRange(_ glyphRange: NSRange, actualGlyphRange actualGlyphRange: NSRangePointer) -> NSRange

    Objective-C

    - (NSRange)characterRangeForGlyphRange:(NSRange)glyphRange actualGlyphRange:(NSRangePointer)actualGlyphRange

    Parameters

    glyphRange

    The glyph range for which to return the character range.

    actualGlyphRange

    If not NULL, on output, points to the full range of glyphs generated by the character range returned. This range may be identical or slightly larger than the requested glyph range. For example, if the text storage contains the character “Ö” and the glyph cache contains the two atomic glyphs “O” and “¨”, and if glyphRange encloses only the first or second glyph, then actualGlyphRange is set to enclose both glyphs.

    Return Value

    The range of characters that generated the glyphs in glyphRange.

    Discussion

    If the length of glyphRange is 0, the resulting character range is a zero-length range just after the character(s) corresponding to the preceding glyph, and actualGlyphRange is also zero-length. If glyphRange extends beyond the text length, the method truncates the result to the number of characters in the text.

    If noncontiguous layout is not enabled, this method forces the generation of glyphs for all characters up to and including the end of the returned range.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the range of glyphs that are generated from the characters in the given character range.

    Declaration

    Swift

    func glyphRangeForCharacterRange(_ charRange: NSRange, actualCharacterRange actualCharRange: NSRangePointer) -> NSRange

    Objective-C

    - (NSRange)glyphRangeForCharacterRange:(NSRange)charRange actualCharacterRange:(NSRangePointer)actualCharRange

    Parameters

    charRange

    The character range for which to return the generated glyph range.

    actualCharRange

    If not NULL, on output, points to the actual range of characters that fully define the glyph range returned. This range may be identical to or slightly larger than the requested character range. For example, if the text storage contains the characters "O" and "¨“, and the glyph store contains the single precomposed glyph "¨Ö”, and if charRange encloses only the first or second character, then actualCharRange is set to enclose both characters.

    Return Value

    The range of glyphs generated by charRange.

    Discussion

    If the length of charRange is 0, the resulting glyph range is a zero-length range just after the glyph(s) corresponding to the preceding character, and actualCharRange will also be zero-length. If charRange extends beyond the text length, the method truncates the result to the number of glyphs in the text.

    If noncontiguous layout is not enabled, this method forces the generation of glyphs for all characters up to and including the end of the specified range.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the value of the attribute identified by the given attribute tag for the glyph at the given index.

    Declaration

    Swift

    func intAttribute(_ attributeTag: Int, forGlyphAtIndex glyphIndex: Int) -> Int

    Objective-C

    - (NSInteger)intAttribute:(NSInteger)attributeTag forGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    attributeTag

    The attribute whose value is returned.

    glyphIndex

    Index of the glyph whose attribute value is returned.

    Return Value

    The value of the attribute identified by attributeTag and glyphIndex.

    Discussion

    Subclasses that define their own custom attributes must override this method to access their own storage for the attribute values. Nonnegative tags are reserved by Apple; you can define your own attributes with negative tags and set values using setIntAttribute:value:forGlyphAtIndex:.

    If noncontiguous layout is not enabled, this method causes generation of all glyphs up to and including glyphIndex. This method is primarily for the use of the glyph generator and typesetter.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets a custom attribute value for a given glyph.

    Declaration

    Swift

    func setIntAttribute(_ attributeTag: Int, value val: Int, forGlyphAtIndex glyphIndex: Int)

    Objective-C

    - (void)setIntAttribute:(NSInteger)attributeTag value:(NSInteger)val forGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    attributeTag

    The custom attribute.

    val

    The new attribute value.

    glyphIndex

    Index of the glyph whose attribute is set.

    Discussion

    Custom attributes are glyph attributes such as NSGlyphInscription or attributes defined by subclasses. Nonnegative tags are reserved by Apple; you can define your own attributes with negative tags and set values using this method.

    This method is part of the NSGlyphStorage protocol, for use by the glyph generator to set attributes. It is not usually necessary for anyone but the glyph generator (and perhaps the typesetter) to call it. It is provided as a public method so subclasses can extend it to accept other glyph attributes. To add new glyph attributes to the text system you must do two things. First, you need to arrange for the glyph generator or typesetter to generate and interpret it. Second, you need to subclass NSLayoutManager to provide someplace to store the new attribute, overriding this method and intAttribute:forGlyphAtIndex: to recognize the new attribute tags and respond to them, while passing any other attributes to the superclass implementation. The NSLayoutManager implementation understands the glyph attributes which it is prepared to store, as enumerated in Glyph Attributes.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the size at which the given glyph (assumed to be an attachment) is asked to draw in the given glyph range.

    Declaration

    Swift

    func setAttachmentSize(_ attachmentSize: NSSize, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setAttachmentSize:(NSSize)attachmentSize forGlyphRange:(NSRange)glyphRange

    Parameters

    attachmentSize

    The glyph size to set.

    glyphRange

    The attachment glyph’s position in the glyph stream.

    Discussion

    For a glyph corresponding to an attachment, this method should be called to set the size for the attachment cell to occupy. The glyph's value should be NSControlGlyph.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • For a glyph corresponding to an attachment, returns the size for the attachment cell to occupy.

    Declaration

    Swift

    func attachmentSizeForGlyphAtIndex(_ glyphIndex: Int) -> NSSize

    Objective-C

    - (NSSize)attachmentSizeForGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    The index of the attachment glyph.

    Return Value

    The size for the attachment cell to occupy. Returns {-1.0, -1.0} if there is no attachment laid for the specified glyph.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the default scaling behavior to the given scaling if an attachment image is too large to fit in a text container.

    Declaration

    Swift

    var defaultAttachmentScaling: NSImageScaling

    Objective-C

    @property NSImageScaling defaultAttachmentScaling

    Parameters

    scaling

    The scaling behavior to set. See NSImageScaling for possible values. The default is NSScaleNone, meaning that images clip rather than scaling.

    Discussion

    Attachment cells control their own size and drawing, so this setting is only advisory to them, but Application Kit–supplied attachment cells respect it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the default behavior desired if an attachment image is too large to fit in a text container.

    Declaration

    Swift

    var defaultAttachmentScaling: NSImageScaling

    Objective-C

    @property NSImageScaling defaultAttachmentScaling

    Discussion

    Attachment cells control their own size and drawing, so this setting is only advisory to them, but Application Kit–supplied attachment cells respect it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Draws an attachment cell.

    Declaration

    Swift

    func showAttachmentCell(_ cell: NSCell, inRect rect: NSRect, characterIndex attachmentIndex: Int)

    Objective-C

    - (void)showAttachmentCell:(NSCell *)cell inRect:(NSRect)rect characterIndex:(NSUInteger)attachmentIndex

    Parameters

    cell

    The attachment cell to draw.

    rect

    The rectangle within which to draw cell.

    attachmentIndex

    The location of the attachment cell.

    Discussion

    The attachmentIndex parameter is provided for cells that alter their appearance based on their location.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets text container where the glyphs in the given range are laid out.

    Declaration

    Swift

    func setTextContainer(_ aTextContainer: NSTextContainer, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setTextContainer:(NSTextContainer *)aTextContainer forGlyphRange:(NSRange)glyphRange

    Parameters

    aTextContainer

    The text container to set.

    glyphRange

    The range of glyphs to lay out.

    Discussion

    The layout within the container is specified with the setLineFragmentRect:forGlyphRange:usedRect: and setLocation:forStartOfGlyphRange: methods.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the range of glyphs laid out within the given text container.

    Declaration

    Swift

    func glyphRangeForTextContainer(_ container: NSTextContainer) -> NSRange

    Objective-C

    - (NSRange)glyphRangeForTextContainer:(NSTextContainer *)container

    Discussion

    This is a less efficient method than the similar textContainerForGlyphAtIndex:effectiveRange:.

    Performs glyph generation and layout if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the container in which the given glyph is laid out and (optionally) by reference the whole range of glyphs that are in that container.

    Declaration

    Swift

    func textContainerForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer) -> NSTextContainer?

    Objective-C

    - (NSTextContainer *)textContainerForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange

    Parameters

    glyphIndex

    Index of a glyph in the returned container.

    effectiveGlyphRange

    If not NULL, on output, points to the whole range of glyphs that are in the returned container.

    Return Value

    The text container in which the glyph at glyphIndex is laid out.

    Discussion

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment. If noncontiguous layout is not enabled and effectiveGlyphRange is not NULL, this method additionally causes glyph generation and layout for the entire text container containing the specified glyph.

    Overriding this method is not recommended. Any changes to the returned glyph range should be done at the typesetter level.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the container in which the given glyph is laid out and (optionally) by reference the whole range of glyphs that are in that container.

    Declaration

    Swift

    func textContainerForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer, withoutAdditionalLayout flag: Bool) -> NSTextContainer?

    Objective-C

    - (NSTextContainer *)textContainerForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange withoutAdditionalLayout:(BOOL)flag

    Parameters

    glyphIndex

    Index of a glyph in the returned container.

    effectiveGlyphRange

    If not NULL, on output, points to the whole range of glyphs that are in the returned container.

    flag

    If YEStrue, glyph generation and layout are not performed, so this option should not be used unless layout is known to be complete for the range in question, or unless noncontiguous layout is enabled; if NOfalse, both are performed as needed.

    Return Value

    The text container in which the glyph at glyphIndex is laid out.

    Discussion

    This method is primarily for use from within NSTypesetter, after layout is complete for the range in question, but before the layout manager's call to NSTypesetter has returned. In that case glyph and layout holes have not yet been recalculated, so the layout manager does not yet know that layout is complete for that range, and this variant must be used.

    Overriding this method is not recommended. Any changes to the returned glyph range should be done at the typesetter level.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the bounding rectangle for the glyphs laid out in the given text container.

    Declaration

    Swift

    func usedRectForTextContainer(_ container: NSTextContainer) -> NSRect

    Objective-C

    - (NSRect)usedRectForTextContainer:(NSTextContainer *)container

    Discussion

    Returns the text container's currently used area, which determines the size that the view would need to be in order to display all the glyphs that are currently laid out in the container. This causes neither glyph generation nor layout.

    Used rectangles are always in container coordinates.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    containerSize (NSTextContainer)

  • Returns the index of the character falling under the given point, expressed in the given container's coordinate system.

    Declaration

    Swift

    func characterIndexForPoint(_ point: NSPoint, inTextContainer container: NSTextContainer, fractionOfDistanceBetweenInsertionPoints partialFraction: UnsafeMutablePointer<CGFloat>) -> Int

    Objective-C

    - (NSUInteger)characterIndexForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container fractionOfDistanceBetweenInsertionPoints:(CGFloat *)partialFraction

    Parameters

    point

    The point to test.

    container

    The text container within which the point is tested.

    partialFraction

    A fraction of the distance from the insertion point, logically before the given character to the next one.

    Return Value

    The index of the character falling under point.

    Discussion

    Analogous to glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:, but expressed in character index terms. The method returns the index of the character falling under point, expressed in coordinate system of container; if no character is under the point, the nearest character is returned, where nearest is defined according to the requirements of selection by mouse. However, this is not simply equivalent to taking the result of the corresponding glyph index method and converting it to a character index, because in some cases a single glyph represents more than one selectable character, for example an fi ligature glyph. In that case, there is an insertion point within the glyph, and this method returns one character or the other, depending on whether the specified point lies to the left or the right of that insertion point.

    In general, this method returns only character indexes for which there is an insertion point. The partialFraction is a fraction of the distance from the insertion point, logically before the given character to the next one, which may be either to the right or to the left depending on directionality.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

  • Associates the given line fragment bounds with the given range of glyphs.

    Declaration

    Swift

    func setLineFragmentRect(_ fragmentRect: NSRect, forGlyphRange glyphRange: NSRange, usedRect usedRect: NSRect)

    Objective-C

    - (void)setLineFragmentRect:(NSRect)fragmentRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRect)usedRect

    Parameters

    fragmentRect

    The rectangle of the line fragment.

    glyphRange

    The range of glyphs to be associated with fragmentRect.

    usedRect

    The portion of fragmentRect that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding. Must be equal to or contained within fragmentRect.

    Discussion

    The typesetter must specify the text container first with setTextContainer:forGlyphRange:, and it sets the exact positions of the glyphs afterwards with setLocation:forStartOfGlyphRange:.

    In the course of layout, all glyphs should end up being included in a range passed to this method, but only glyphs that start a new line fragment should be at the start of such ranges.

    Line fragment rectangles and line fragment used rectangles are always in container coordinates.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle for the line fragment in which the given glyph is laid out and (optionally), by reference, the whole range of glyphs that are in that fragment.

    Declaration

    Swift

    func lineFragmentRectForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer) -> NSRect

    Objective-C

    - (NSRect)lineFragmentRectForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange

    Parameters

    glyphIndex

    The glyph for which to return the line fragment rectangle.

    effectiveGlyphRange

    If not NULL, on output, the range for all glyphs in the line fragment.

    Return Value

    The line fragment in which the given glyph is laid out.

    Discussion

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, for all of the text up to and including that line fragment.

    Line fragment rectangles are always in container coordinates.

    Overriding this method is not recommended. If the the line fragment rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect:forGlyphRange:usedRect:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the line fragment rectangle containing the glyph at the given glyph index.

    Declaration

    Swift

    func lineFragmentRectForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer, withoutAdditionalLayout flag: Bool) -> NSRect

    Objective-C

    - (NSRect)lineFragmentRectForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange withoutAdditionalLayout:(BOOL)flag

    Parameters

    glyphIndex

    The glyph for which to return the line fragment rectangle.

    effectiveGlyphRange

    If not NULL, on output, the range for all glyphs in the line fragment.

    flag

    If YEStrue, glyph generation and layout are not performed, so this option should not be used unless layout is known to be complete for the range in question, or unless noncontiguous layout is enabled; if NOfalse, both are performed as needed.

    Return Value

    The line fragment in which the given glyph is laid out.

    Discussion

    This method is primarily for use from within NSTypesetter, after layout is complete for the range in question, but before the layout manager's call to NSTypesetter has returned. In that case glyph and layout holes have not yet been recalculated, so the layout manager does not yet know that layout is complete for that range, and this variant must be used.

    Overriding this method is not recommended. If the the line fragment rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect:forGlyphRange:usedRect:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns the usage rectangle for the line fragment in which the given glyph is laid and (optionally) by reference the whole range of glyphs that are in that fragment.

    Declaration

    Swift

    func lineFragmentUsedRectForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer) -> NSRect

    Objective-C

    - (NSRect)lineFragmentUsedRectForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange

    Parameters

    glyphIndex

    The glyph for which to return the line fragment used rectangle.

    effectiveGlyphRange

    If not NULL, on output, the range for all glyphs in the line fragment.

    Return Value

    The used rectangle for the line fragment in which the given glyph is laid out.

    Discussion

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

    Line fragment used rectangles are always in container coordinates.

    Overriding this method is not recommended. If the the line fragment used rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect:forGlyphRange:usedRect:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the usage rectangle for the line fragment in which the given glyph is laid and (optionally) by reference the whole range of glyphs that are in that fragment.

    Declaration

    Swift

    func lineFragmentUsedRectForGlyphAtIndex(_ glyphIndex: Int, effectiveRange effectiveGlyphRange: NSRangePointer, withoutAdditionalLayout flag: Bool) -> NSRect

    Objective-C

    - (NSRect)lineFragmentUsedRectForGlyphAtIndex:(NSUInteger)glyphIndex effectiveRange:(NSRangePointer)effectiveGlyphRange withoutAdditionalLayout:(BOOL)flag

    Parameters

    glyphIndex

    The glyph for which to return the line fragment used rectangle.

    effectiveGlyphRange

    If not NULL, on output, the range for all glyphs in the line fragment.

    flag

    If YEStrue, glyph generation and layout are not performed, so this option should not be used unless layout is known to be complete for the range in question, or unless noncontiguous layout is enabled; if NOfalse, both are performed as needed.

    Return Value

    The used rectangle for the line fragment in which the given glyph is laid out.

    Discussion

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

    Line fragment used rectangles are always in container coordinates.

    Overriding this method is not recommended. If the the line fragment used rectangle needs to be modified, that should be done at the typesetter level or by calling setLineFragmentRect:forGlyphRange:usedRect:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Sets the bounds and container for the extra line fragment.

    Declaration

    Swift

    func setExtraLineFragmentRect(_ aRect: NSRect, usedRect usedRect: NSRect, textContainer aTextContainer: NSTextContainer?)

    Objective-C

    - (void)setExtraLineFragmentRect:(NSRect)aRect usedRect:(NSRect)usedRect textContainer:(NSTextContainer *)aTextContainer

    Parameters

    aRect

    The rectangle to set.

    usedRect

    Indicates where the insertion point is drawn.

    aTextContainer

    The text container where the rectangle is to be laid out.

    Discussion

    The extra line fragment is used when the text backing ends with a hard line break or when the text backing is totally empty, to define the extra line which needs to be displayed at the end of the text. If the text backing is not empty and does not end with a hard line break, this should be set to NSZeroRect and nil.

    Line fragment rectangles and line fragment used rectangles are always in container coordinates.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle defining the extra line fragment for the insertion point at the end of a text (either in an empty text or after a final paragraph separator).

    Declaration

    Swift

    var extraLineFragmentRect: NSRect { get }

    Objective-C

    @property(readonly) NSRect extraLineFragmentRect

    Return Value

    The rectangle defining the extra line fragment for the insertion point.

    Discussion

    The rectangle is defined in the coordinate system of its NSTextContainer. Returns NSZeroRect if there is no such rectangle.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the rectangle enclosing the insertion point drawn in the extra line fragment rectangle.

    Declaration

    Swift

    var extraLineFragmentUsedRect: NSRect { get }

    Objective-C

    @property(readonly) NSRect extraLineFragmentUsedRect

    Return Value

    The rectangle enclosing the insertion point.

    Discussion

    The rectangle is defined in the coordinate system of its NSTextContainer. Returns NSZeroRect if there is no extra line fragment rectangle.

    The extra line fragment used rectangle is twice as wide (or tall) as the text container’s line fragment padding, with the insertion point itself in the middle.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the text container that contains the extra line fragment rectangle.

    Declaration

    Swift

    var extraLineFragmentTextContainer: NSTextContainer? { get }

    Objective-C

    @property(readonly, strong) NSTextContainer *extraLineFragmentTextContainer

    Return Value

    The text container that contains the extra line fragment rectangle, or nil if there is no extra line fragment rectangle.

    Discussion

    This rectangle is used to display the insertion point at the end of a text (either in an empty text or after a final paragraph separator).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether the given glyph exceeds the bounds of the line fragment where it’s laid out.

    Declaration

    Swift

    func setDrawsOutsideLineFragment(_ flag: Bool, forGlyphAtIndex glyphIndex: Int)

    Objective-C

    - (void)setDrawsOutsideLineFragment:(BOOL)flag forGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    flag

    If YEStrue, sets the given glyph to draw outside its line fragment; if NOfalse, the glyph does not draw outside.

    glyphIndex

    Index of the glyph to set.

    Discussion

    This can happen when text is set at a fixed line height. For example, if the user specifies a fixed line height of 12 points and sets the font size to 24 points, the glyphs will exceed their layout rectangles. This information is important for determining whether additional lines need to be redrawn as a result of changes to any given line fragment.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the glyph draws outside of its line fragment rectangle.

    Declaration

    Swift

    func drawsOutsideLineFragmentForGlyphAtIndex(_ glyphIndex: Int) -> Bool

    Objective-C

    - (BOOL)drawsOutsideLineFragmentForGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    Index of the glyph.

    Return Value

    YEStrue if the glyph at glyphIndex exceeds the bounds of the line fragment where it’s laid out, NOfalse otherwise.

    Discussion

    Exceeding bounds can happen when text is set at a fixed line height. For example, if the user specifies a fixed line height of 12 points and sets the font size to 24 points, the glyphs will exceed their layout rectangles.

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

    Glyphs that draw outside their line fragment rectangles aren’t considered when calculating enclosing rectangles with the rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount: and rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount: methods. They are, however, considered by boundingRectForGlyphRange:inTextContainer:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the location for the first glyph of the given range.

    Declaration

    Swift

    func setLocation(_ aPoint: NSPoint, forStartOfGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setLocation:(NSPoint)aPoint forStartOfGlyphRange:(NSRange)glyphRange

    Parameters

    aPoint

    The location to which the first glyph is set, relative to the origin of the glyph’s line fragment origin.

    glyphRange

    The glyphs whose location is set.

    Discussion

    Setting the location for a glyph range implies that its first glyph is not nominally spaced with respect to the previous glyph. In the course of layout, all glyphs should end up being included in a range passed to this method, but only glyphs that start a new nominal range should be at the start of such ranges. The first glyph in a line fragment should always start a new nominal range. Glyph locations are given relative to their line fragment rectangle's origin.

    Before setting the location for a glyph range, you must specify the text container with setTextContainer:forGlyphRange: and the line fragment rectangle with setLineFragmentRect:forGlyphRange:usedRect:.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets locations for many glyph ranges at once.

    Declaration

    Swift

    func setLocations(_ locations: NSPointArray, startingGlyphIndexes glyphIndexes: UnsafeMutablePointer<Int>, count count: Int, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setLocations:(NSPointArray)locations startingGlyphIndexes:(NSUInteger *)glyphIndexes count:(NSUInteger)count forGlyphRange:(NSRange)glyphRange

    Parameters

    locations

    The locations to which the first glyph in each range is set, relative to the origin of the glyph’s line fragment origin.

    glyphIndexes

    Indexes in glyphRange of the glyphs whose locations are set.

    count

    The number of glyphs whose locations are set.

    glyphRange

    The entire glyph range containing all the glyphs whose locations are set.

    Discussion

    This method enables the typesetter to set locations for glyph ranges in bulk. All of the specified glyph indexes should lie within the specified glyph range. The first of them should be equal to glyphRange.location, and the remainder should increase monotonically. Each location is set as the location for the range beginning at the corresponding glyph index, and continuing until the subsequent glyph index, or until the end of the glyph range for the last location. Thus this method is equivalent to calling setLocation:forStartOfGlyphRange: for a set of ranges covering all of the glyphs in glyphRange.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the location for the given glyph within its line fragment.

    Declaration

    Swift

    func locationForGlyphAtIndex(_ glyphIndex: Int) -> NSPoint

    Objective-C

    - (NSPoint)locationForGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    The glyph whose location is returned.

    Return Value

    The location of the given glyph.

    Discussion

    If the given glyph does not have an explicit location set for it (for example, if it is part of (but not first in) a sequence of nominally spaced characters), the location is calculated by glyph advancements from the location of the most recent preceding glyph with a location set.

    Glyph locations are relative to their line fragment rectangle's origin. The line fragment rectangle in turn is defined in the coordinate system of the text container where it resides.

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the range for the glyphs around the given glyph that can be displayed using only their advancements from the font, without pairwise kerning or other adjustments to spacing.

    Declaration

    Swift

    func rangeOfNominallySpacedGlyphsContainingIndex(_ glyphIndex: Int) -> NSRange

    Objective-C

    - (NSRange)rangeOfNominallySpacedGlyphsContainingIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    Index of the glyph to test.

    Return Value

    The range of nominally spaced glyphs.

    Discussion

    The range returned begins with the first glyph, counting back from glyphIndex, that has a location set, and it continues up to, but does not include, the next glyph that has a location set.

    Performs glyph generation and layout if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns insertion points in bulk for a given line fragment.

    Declaration

    Swift

    func getLineFragmentInsertionPointsForCharacterAtIndex(_ charIndex: Int, alternatePositions aFlag: Bool, inDisplayOrder dFlag: Bool, positions positions: UnsafeMutablePointer<CGFloat>, characterIndexes charIndexes: UnsafeMutablePointer<Int>) -> Int

    Objective-C

    - (NSUInteger)getLineFragmentInsertionPointsForCharacterAtIndex:(NSUInteger)charIndex alternatePositions:(BOOL)aFlag inDisplayOrder:(BOOL)dFlag positions:(CGFloat *)positions characterIndexes:(NSUInteger *)charIndexes

    Parameters

    charIndex

    The character index of one character within the line fragment.

    aFlag

    If YEStrue, returns alternate, rather than primary, insertion points.

    dFlag

    If YEStrue, returns insertion points in display, rather than logical, order.

    positions

    On output, the positions of the insertion points, in the order specified.

    charIndexes

    On output, the indexes of the characters corresponding to the returned insertion points.

    Return Value

    The number of insertion points returned.

    Discussion

    The method allows clients to obtain all insertion points for a line fragment in one call. Each pointer passed in should either be NULL or else point to sufficient memory to hold as many elements as there are insertion points in the line fragment (which cannot be more than the number of characters + 1). The returned positions indicate a transverse offset relative to the line fragment rectangle's origin. Internal caching is used to ensure that repeated calls to this method for the same line fragment (possibly with differing values for other arguments) are not significantly more expensive than a single call.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given character range.

    Declaration

    Swift

    func rectArrayForCharacterRange(_ charRange: NSRange, withinSelectedCharacterRange selCharRange: NSRange, inTextContainer container: NSTextContainer, rectCount rectCount: UnsafeMutablePointer<Int>) -> NSRectArray

    Objective-C

    - (NSRectArray)rectArrayForCharacterRange:(NSRange)charRange withinSelectedCharacterRange:(NSRange)selCharRange inTextContainer:(NSTextContainer *)container rectCount:(NSUInteger *)rectCount

    Parameters

    charRange

    The character range for which to return rectangles.

    selCharRange

    Selected characters within charRange, which can affect the size of the rectangles; it must be equal to or contain charRange. If the caller is interested in this more from an enclosing point of view rather than a selection point of view, pass {NSNotFound, 0} as the selected range.

    container

    The text container in which the text is laid out.

    rectCount

    The number of rectangles returned.

    Return Value

    The array of rectangles enclosing the given range.

    Discussion

    These rectangles can be used to draw the text background or highlight for the given range of characters. If a selected range is given in selCharRange, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles and supplying a selected range is the clue this method uses to determine whether to go to the trouble of doing this special work.

    This method will do the minimum amount of work required to answer the question. The resulting array is owned by the layout manager and will be reused when this method, rectArrayForGlyphRange:withinSelectedGlyphRange:inTextContainer:rectCount:, or boundingRectForGlyphRange:inTextContainer: is called. One of these methods may be called indirectly. If you aren't going to use the rectangles right away, you should copy them to another location. These rectangles are always in container coordinates.

    The number of rectangles returned isn’t necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.

    These rectangles don’t necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange:inTextContainer: to determine the area that contains all drawing performed for a range of glyphs.

    Performs glyph generation and layout if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an array of rectangles and, by reference, the number of such rectangles, that define the region in the given container enclosing the given glyph range.

    Declaration

    Swift

    func rectArrayForGlyphRange(_ glyphRange: NSRange, withinSelectedGlyphRange selGlyphRange: NSRange, inTextContainer container: NSTextContainer, rectCount rectCount: UnsafeMutablePointer<Int>) -> NSRectArray

    Objective-C

    - (NSRectArray)rectArrayForGlyphRange:(NSRange)glyphRange withinSelectedGlyphRange:(NSRange)selGlyphRange inTextContainer:(NSTextContainer *)container rectCount:(NSUInteger *)rectCount

    Parameters

    glyphRange

    The glyph range for which to return rectangles.

    selGlyphRange

    Selected glyphs within glyphRange, which can affect the size of the rectangles; it must be equal to or contain glyphRange. If the caller is interested in this more from an enclosing point of view rather than a selection point of view, pass {NSNotFound, 0} as the selected range.

    container

    The text container in which the text is laid out.

    rectCount

    The number of rectangles returned.

    Return Value

    The array of rectangles enclosing the given range.

    Discussion

    These rectangles can be used to draw the text background or highlight for the given range of characters. If a selected range is given in selGlyphRange, the rectangles returned are correct for drawing the selection. Selection rectangles are generally more complicated than enclosing rectangles and supplying a selected range is the clue this method uses to determine whether to go to the trouble of doing this special work.

    The number of rectangles returned isn’t necessarily the number of lines enclosing the specified range. Contiguous lines can share an enclosing rectangle, and lines broken into several fragments have a separate enclosing rectangle for each fragment.

    This method will do the minimum amount of work required to answer the question. The resulting array is owned by the layout manager and will be reused when this method, rectArrayForCharacterRange:withinSelectedCharacterRange:inTextContainer:rectCount:, or boundingRectForGlyphRange:inTextContainer: is called. One of these methods may be called indirectly. If you aren't going to use the rectangles right away, you should copy them to another location. These rectangles are always in container coordinates.

    The purpose of this method is to calculate line rectangles for drawing the text background and highlighting. These rectangles don’t necessarily enclose glyphs that draw outside their line fragment rectangles; use boundingRectForGlyphRange:inTextContainer: to determine the area that contains all drawing performed for a range of glyphs.

    Performs glyph generation and layout if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a single bounding rectangle (in container coordinates) enclosing all glyphs and other marks drawn in the given text container for the given glyph range, including glyphs that draw outside their line fragment rectangles and text attributes such as underlining.

    Declaration

    Swift

    func boundingRectForGlyphRange(_ glyphRange: NSRange, inTextContainer container: NSTextContainer) -> NSRect

    Objective-C

    - (NSRect)boundingRectForGlyphRange:(NSRange)glyphRange inTextContainer:(NSTextContainer *)container

    Parameters

    glyphRange

    The range of glyphs for which to return the bounding rectangle.

    container

    The text container in which the glyphs are laid out.

    Return Value

    The bounding rectangle enclosing the given range of glyphs.

    Discussion

    The range is intersected with the container's range before computing the bounding rectangle. This method can be used to translate glyph ranges into display rectangles for invalidation and redrawing when a range of glyphs changes. Bounding rectangles are always in container coordinates.

    Performs glyph generation and layout if needed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the smallest contiguous range for glyphs that are laid out wholly or partially within the given rectangle in the given text container.

    Declaration

    Swift

    func glyphRangeForBoundingRect(_ bounds: NSRect, inTextContainer container: NSTextContainer) -> NSRange

    Objective-C

    - (NSRange)glyphRangeForBoundingRect:(NSRect)bounds inTextContainer:(NSTextContainer *)container

    Parameters

    bounds

    The bounding rectangle for which to return glyphs.

    container

    The text container in which the glyphs are laid out.

    Return Value

    The range of glyphs that would need to be displayed in order to draw all glyphs that fall (even partially) within the given bounding rectangle. The range returned can include glyphs that don’t fall inside or intersect bounds, although the first and last glyphs in the range always do. At most this method returns the glyph range for the whole container.

    Discussion

    This method is used to determine which glyphs need to be displayed within a given rectangle.

    Performs glyph generation and layout if needed. Bounding rectangles are always in container coordinates.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the smallest contiguous range for glyphs that are laid out wholly or partially within the given rectangle in the given text container.

    Declaration

    Swift

    func glyphRangeForBoundingRectWithoutAdditionalLayout(_ bounds: NSRect, inTextContainer container: NSTextContainer) -> NSRange

    Objective-C

    - (NSRange)glyphRangeForBoundingRectWithoutAdditionalLayout:(NSRect)bounds inTextContainer:(NSTextContainer *)container

    Parameters

    bounds

    The bounding rectangle for which to return glyphs.

    container

    The text container in which the glyphs are laid out.

    Return Value

    The range of glyphs that would need to be displayed in order to draw all glyphs that fall (even partially) within the given bounding rectangle. The range returned can include glyphs that don’t fall inside or intersect bounds, although the first and last glyphs in the range always do. At most this method returns the glyph range for the whole container.

    Discussion

    Unlike glyphRangeForBoundingRect:inTextContainer:, this variant of the method doesn’t perform glyph generation or layout. Its results, though faster, can be incorrect. This method is primarily for use by NSTextView; you should rarely need to use it yourself.

    Bounding rectangles are always in container coordinates.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the index of the glyph falling under the given point, expressed in the given container's coordinate system.

    Declaration

    Swift

    func glyphIndexForPoint(_ point: NSPoint, inTextContainer container: NSTextContainer, fractionOfDistanceThroughGlyph partialFraction: UnsafeMutablePointer<CGFloat>) -> Int

    Objective-C

    - (NSUInteger)glyphIndexForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container fractionOfDistanceThroughGlyph:(CGFloat *)partialFraction

    Parameters

    point

    The point for which to return the glyph, in coordinates of container.

    container

    The container in which the returned glyph is laid out.

    partialFraction

    If not NULL, on output, the fraction of the distance between the location of the glyph returned and the location of the next glyph.

    Return Value

    The index of the glyph falling under the given point, expressed in the given container's coordinate system.

    Discussion

    If no glyph is under point, the nearest glyph is returned, where nearest is defined according to the requirements of selection by mouse. Clients who wish to determine whether the the point actually lies within the bounds of the glyph returned should follow this with a call to boundingRectForGlyphRange:inTextContainer: and test whether the point falls in the rectangle returned by that method. If partialFraction is non-NULL, it returns by reference the fraction of the distance between the location of the glyph returned and the location of the next glyph.

    For purposes such as dragging out a selection or placing the insertion point, a partial percentage less than or equal to 0.5 indicates that point should be considered as falling before the glyph index returned; a partial percentage greater than 0.5 indicates that it should be considered as falling after the glyph index returned. If the nearest glyph doesn’t lie under point at all (for example, if point is beyond the beginning or end of a line), this ratio is 0 or 1.

    If the glyph stream contains the glyphs “A” and “b”, with the width of “A” being 13 points, and the user clicks at a location 8 points into “A”, partialFraction is 8/13, or 0.615. In this case, the point given should be considered as falling between “A” and “b” for purposes such as dragging out a selection or placing the insertion point.

    Performs glyph generation and layout if needed.

    As part of its implementation, this method calls fractionOfDistanceThroughGlyphForPoint:inTextContainer: and glyphIndexForPoint:inTextContainer:. To change this method’s behavior, override those two methods instead of this one.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • This method is a primitive for glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:. You should always call the main method, not the primitives.

    Declaration

    Swift

    func fractionOfDistanceThroughGlyphForPoint(_ point: NSPoint, inTextContainer container: NSTextContainer) -> CGFloat

    Objective-C

    - (CGFloat)fractionOfDistanceThroughGlyphForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container

    Discussion

    Overriding should be done for the primitive methods. Existing subclasses that do not do this overriding will not have their implementations available to Java developers.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • This method is a primitive for glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:. You should always call the main method, not the primitives.

    Declaration

    Swift

    func glyphIndexForPoint(_ point: NSPoint, inTextContainer container: NSTextContainer) -> Int

    Objective-C

    - (NSUInteger)glyphIndexForPoint:(NSPoint)point inTextContainer:(NSTextContainer *)container

    Discussion

    Overriding should be done for the primitive methods. Existing subclasses that do not do this overriding will not have their implementations available to Java developers.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the glyph at the given index to be one that isn’t shown.

    Declaration

    Swift

    func setNotShownAttribute(_ flag: Bool, forGlyphAtIndex glyphIndex: Int)

    Objective-C

    - (void)setNotShownAttribute:(BOOL)flag forGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    flag

    If YEStrue, the glyph is not shown; if NOfalse, it is shown.

    glyphIndex

    Index of the glyph whose attribute is set.

    Discussion

    The typesetter decides which glyphs are not shown and sets this attribute in the layout manager to ensure that those glyphs are not displayed. For example, a tab or newline character doesn’t leave any marks; it just indicates where following glyphs are laid out.

    Raises an NSRangeException if glyphIndex is out of bounds.

    This method is used by the layout mechanism and should be invoked only during typesetting, in almost all cases only by the typesetter. For example, a custom typesetter might invoke it.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the glyph at the given index is one that isn’t shown.

    Declaration

    Swift

    func notShownAttributeForGlyphAtIndex(_ glyphIndex: Int) -> Bool

    Objective-C

    - (BOOL)notShownAttributeForGlyphAtIndex:(NSUInteger)glyphIndex

    Parameters

    glyphIndex

    Index of the glyph.

    Return Value

    YEStrue if the glyph at glyphIndex is not shown; otherwise NOfalse.

    Discussion

    Some glyphs are not shown. For example, a tab, newline, or attachment glyph is not shown; it just affects the layout of following glyphs or locates the attachment graphic. Space characters, however, typically are shown as glyphs with a displacement, although they leave no visible marks.

    This method causes glyph generation and layout for the line fragment containing the specified glyph, or if noncontiguous layout is not enabled, up to and including that line fragment.

    Raises an NSRangeException if glyphIndex is out of bounds.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether to substitute visible glyphs for whitespace and other typically invisible characters in layout.

    Declaration

    Swift

    var showsInvisibleCharacters: Bool

    Objective-C

    @property BOOL showsInvisibleCharacters

    Parameters

    flag

    If YEStrue, the receiver substitutes visible glyphs for invisible characters if the font and script support it; if NOfalse, it doesn’t. The default is NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the receiver substitutes visible glyphs for whitespace and other typically invisible characters in layout.

    Declaration

    Swift

    var showsInvisibleCharacters: Bool

    Objective-C

    @property BOOL showsInvisibleCharacters

    Return Value

    YEStrue if the receiver substitutes visible glyphs for invisible characters if the font and script support it; otherwise NOfalse. The default is NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether to substitute visible glyphs for control characters in layout.

    Declaration

    Swift

    var showsControlCharacters: Bool

    Objective-C

    @property BOOL showsControlCharacters

    Parameters

    flag

    If YEStrue, the receiver substitutes visible glyphs for control characters if the font and script support it; if NOfalse, it doesn’t. The default is NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the receiver substitutes visible glyphs for control characters.

    Declaration

    Swift

    var showsControlCharacters: Bool

    Objective-C

    @property BOOL showsControlCharacters

    Return Value

    YEStrue if the receiver substitutes visible glyphs for control characters if the font and script support it; NOfalse if it doesn’t.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the layout manager’s current layout options.

    Declaration

    Swift

    var layoutOptions: Int { get }

    Objective-C

    @property(readonly) NSUInteger layoutOptions

    Return Value

    A bit mask representing the current layout options as defined in Layout Options in NSGlyphStorage Protocol Reference.

    Discussion

    This method is part of the NSGlyphStorage protocol, for use by the glyph generator. It enables the glyph generator to ask which options the layout manager requests.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sets the threshold controlling when hyphenation is done.

    Declaration

    Swift

    var hyphenationFactor: Float

    Objective-C

    @property float hyphenationFactor

    Parameters

    factor

    The hyphenation factor, ranging from 0.0 to 1.0. By default, the value is 0.0, meaning hyphenation is off. A factor of 1.0 causes hyphenation to be attempted always.

    Discussion

    Whenever (width of the real contents of the line) / (the line fragment width) is below factor, hyphenation is attempted when laying out the line. Hyphenation slows down text layout and increases memory usage, so it should be used sparingly.

    May be overridden on a per-paragraph basis by the NSParagraphStyle method hyphenationFactor.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the current hyphenation threshold.

    Declaration

    Swift

    var hyphenationFactor: Float

    Objective-C

    @property float hyphenationFactor

    Return Value

    The hyphenation factor ranging from 0.0 to 1.0. By default, the value is 0.0, meaning hyphenation is off. A value of 1.0 causes hyphenation to be attempted always.

    Discussion

    Whenever (width of the real contents of the line) / (the line fragment width) is less than hyphenationFactor, hyphenation is attempted when laying out the line. Hyphenation slows down text layout and increases memory usage, so it should be used sparingly.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the indexes for the first character and glyph that have invalid layout information.

    Declaration

    Swift

    func getFirstUnlaidCharacterIndex(_ charIndex: UnsafeMutablePointer<Int>, glyphIndex glyphIndex: UnsafeMutablePointer<Int>)

    Objective-C

    - (void)getFirstUnlaidCharacterIndex:(NSUInteger *)charIndex glyphIndex:(NSUInteger *)glyphIndex

    Parameters

    charIndex

    On return, if not NULL, the index of the first character that has invalid layout information

    glyphIndex

    On return, if not NULL, the index of the first glyph that has invalid layout information.

    Discussion

    Either parameter may be NULL, in which case the receiver simply ignores it.

    As part of its implementation, this method calls firstUnlaidCharacterIndex and firstUnlaidGlyphIndex. To change this method’s behavior, override those two methods instead of this one.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the index for the first character in the layout manager that has not been laid out.

    Declaration

    Swift

    var firstUnlaidCharacterIndex: Int { get }

    Objective-C

    @property(readonly) NSUInteger firstUnlaidCharacterIndex

    Return Value

    The character index.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the index for the first glyph in the layout manager that has not been laid out.

    Declaration

    Swift

    var firstUnlaidGlyphIndex: Int { get }

    Objective-C

    @property(readonly) NSUInteger firstUnlaidGlyphIndex

    Return Value

    The glyph index.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Controls using screen fonts to calculate layout and display text.

    Declaration

    Swift

    var usesScreenFonts: Bool

    Objective-C

    @property BOOL usesScreenFonts

    Parameters

    flag

    If YEStrue, the receiver uses screen fonts; if NOfalse, it doesn’t.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the receiver uses screen fonts to calculate layout and display text.

    Declaration

    Swift

    var usesScreenFonts: Bool

    Objective-C

    @property BOOL usesScreenFonts

    Return Value

    YEStrue if the receiver calculates layout and displays text using screen fonts when possible; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a screen font suitable for use in place of the given font, if one is available.

    Declaration

    Swift

    func substituteFontForFont(_ originalFont: NSFont) -> NSFont

    Objective-C

    - (NSFont *)substituteFontForFont:(NSFont *)originalFont

    Parameters

    originalFont

    The font to replace.

    Return Value

    A screen font suitable for use in place of originalFont, or simply originalFont if a screen font can’t be used or isn’t available.

    Discussion

    A screen font can be substituted if the receiver is set to use screen fonts and if no NSTextView associated with the receiver is scaled or rotated.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the the accessory view that the text system uses for its ruler.

    Declaration

    Swift

    func rulerAccessoryViewForTextView(_ view: NSTextView?, paragraphStyle style: NSParagraphStyle, ruler ruler: NSRulerView, enabled isEnabled: Bool) -> NSView?

    Objective-C

    - (NSView *)rulerAccessoryViewForTextView:(NSTextView *)view paragraphStyle:(NSParagraphStyle *)style ruler:(NSRulerView *)ruler enabled:(BOOL)isEnabled

    Parameters

    view

    The text view using the layout manager.

    style

    Sets the state of the controls in the accessory view; must not be nil.

    ruler

    The ruler view whose accessory view is returned.

    isEnabled

    If YEStrue, the accessory view is enabled and accepts mouse and keyboard events; if NOfalse it’s disabled.

    Return Value

    The accessory view containing tab wells, text alignment buttons, and so on.

    Discussion

    If you have turned off automatic ruler updating through the use of setUsesRuler: so that you can do more complex things, but you still want to display the appropriate accessory view, you can use this method.

    This method is invoked automatically by the NSTextView object using the layout manager. You should rarely need to invoke it, but you can override it to customize ruler support. If you do use this method directly, note that it neither installs the ruler accessory view nor sets the markers for the NSRulerView object. You must install the accessory view into the ruler using the NSRulerView method setAccessoryView:. To set the markers, use rulerMarkersForTextView:paragraphStyle:ruler: to get the markers needed, and then send setMarkers: to the ruler.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    horizontalRulerView (NSScrollView)

  • Returns an array of text ruler objects for the current selection.

    Declaration

    Swift

    func rulerMarkersForTextView(_ view: NSTextView?, paragraphStyle style: NSParagraphStyle, ruler ruler: NSRulerView) -> [AnyObject]

    Objective-C

    - (NSArray *)rulerMarkersForTextView:(NSTextView *)view paragraphStyle:(NSParagraphStyle *)style ruler:(NSRulerView *)ruler

    Parameters

    view

    The text view using the layout manager.

    style

    Sets the state of the controls in the accessory view; must not be nil.

    ruler

    The ruler view whose ruler markers are returned.

    Return Value

    An array of NSRulerMarker objects representing such things as left and right margins, first-line indent, and tab stops.

    Discussion

    If you have turned off automatic ruler updating through the use of setUsesRuler: so that you can do more complex things, but you still want to display the appropriate accessory view, you can use this method.

    This method is invoked automatically by the NSTextView object using the layout manager. You should rarely need to invoke it, but you can override it to add new kinds of markers or otherwise customize ruler support.

    You can set the returned ruler markers with the NSRulerView method setMarkers:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Indicates whether the first responder in the given window is a text view associated with the receiver.

    Declaration

    Swift

    func layoutManagerOwnsFirstResponderInWindow(_ window: NSWindow) -> Bool

    Objective-C

    - (BOOL)layoutManagerOwnsFirstResponderInWindow:(NSWindow *)window

    Parameters

    window

    The window whose first responder is tested.

    Return Value

    YEStrue if the first responder in window is a text view associated with the receiver; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the first text view in the receiver’s series of text views.

    Declaration

    Swift

    unowned(unsafe) var firstTextView: NSTextView? { get }

    Objective-C

    @property(readonly, assign) NSTextView *firstTextView

    Return Value

    The receiver’s first text view.

    Discussion

    This NSTextView object is the recipient of various NSText and NSTextView notifications.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the text view containing the first glyph in the selection.

    Declaration

    Swift

    unowned(unsafe) var textViewForBeginningOfSelection: NSTextView? { get }

    Objective-C

    @property(readonly, assign) NSTextView *textViewForBeginningOfSelection

    Return Value

    The text view containing the first glyph in the selection, or nil if there’s no selection or there isn’t enough layout information to determine the text view.

    Discussion

    This method does not cause layout if the beginning of the selected range is not yet laid out.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the current typesetter.

    Declaration

    Swift

    var typesetter: NSTypesetter!

    Objective-C

    @property(strong) NSTypesetter *typesetter

    Parameters

    typesetter

    The typesetter for the receiver.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – typesetter

  • Returns the receiver’s typesetter.

    Declaration

    Swift

    var typesetter: NSTypesetter!

    Objective-C

    @property(strong) NSTypesetter *typesetter

    Return Value

    The receiver’s typesetter.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the default typesetter behavior.

    Declaration

    Swift

    var typesetterBehavior: NSTypesetterBehavior

    Objective-C

    @property NSTypesetterBehavior typesetterBehavior

    Parameters

    theBehavior

    An NSTypesetterBehavior constant that specifies the behavior for the receiver.

    Discussion

    The typesetter behavior affects glyph spacing and line height.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the current typesetter behavior.

    Declaration

    Swift

    var typesetterBehavior: NSTypesetterBehavior

    Objective-C

    @property NSTypesetterBehavior typesetterBehavior

    Return Value

    The current typesetter behavior value.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the default line height for a line of text drawn using a given font.

    Declaration

    Swift

    func defaultLineHeightForFont(_ theFont: NSFont) -> CGFloat

    Objective-C

    - (CGFloat)defaultLineHeightForFont:(NSFont *)theFont

    Parameters

    theFont

    The font for which to determine the default line height.

    Return Value

    The default line height for a line of text drawn using theFont.

    Discussion

    The value returned may vary according to the layout manager’s typesetter behavior.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the default baseline offset specified by the layout manager's typesetter behavior for the given font.

    Declaration

    Swift

    func defaultBaselineOffsetForFont(_ theFont: NSFont) -> CGFloat

    Objective-C

    - (CGFloat)defaultBaselineOffsetForFont:(NSFont *)theFont

    Parameters

    theFont

    The font for which to return the default baseline offset.

    Return Value

    The default baseline offset for a line of text drawn using theFont.

    Discussion

    The value returned may vary according to the layout manager’s typesetter behavior.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Enables or disables noncontiguous layout.

    Declaration

    Swift

    var allowsNonContiguousLayout: Bool

    Objective-C

    @property BOOL allowsNonContiguousLayout

    Parameters

    flag

    If YEStrue, noncontiguous layout is enabled; if NOfalse, noncontiguous layout is disabled.

    Discussion

    Passing YEStrue in flag allows but does not require the layout manager to use noncontiguous layout, and the layout manager may in fact not do so, depending on its configuration.

    For more information about noncontiguous layout, see Noncontiguous Layout.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Indicates whether noncontiguous layout is enabled or disabled.

    Declaration

    Swift

    var allowsNonContiguousLayout: Bool

    Objective-C

    @property BOOL allowsNonContiguousLayout

    Return Value

    YEStrue if noncontiguous layout is enabled; otherwise, NOfalse.

    Discussion

    For more information about noncontiguous layout, see Noncontiguous Layout.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Indicates whether the layout manager currently has any areas of noncontiguous layout.

    Declaration

    Swift

    var hasNonContiguousLayout: Bool { get }

    Objective-C

    @property(readonly) BOOL hasNonContiguousLayout

    Return Value

    YEStrue if noncontiguous layout exists; otherwise, NOfalse.

    Discussion

    There may be times at which there is no noncontiguous layout, such as when layout is complete; this method enables the layout manager to report that to clients.

    For more information about noncontiguous layout, see Noncontiguous Layout.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to generate glyphs for the specified character range, if it has not already done so.

    Declaration

    Swift

    func ensureGlyphsForCharacterRange(_ charRange: NSRange)

    Objective-C

    - (void)ensureGlyphsForCharacterRange:(NSRange)charRange

    Parameters

    charRange

    The character range for which glyphs are generated.

    Discussion

    The layout manager reserves the right to perform glyph generation for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to generate glyphs for the specified glyph range, if it has not already done so.

    Declaration

    Swift

    func ensureGlyphsForGlyphRange(_ glyphRange: NSRange)

    Objective-C

    - (void)ensureGlyphsForGlyphRange:(NSRange)glyphRange

    Parameters

    glyphRange

    The glyph range for which glyphs are generated.

    Discussion

    The layout manager reserves the right to perform glyph generation for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to perform layout for the specified character range, if it has not already done so.

    Declaration

    Swift

    func ensureLayoutForCharacterRange(_ charRange: NSRange)

    Objective-C

    - (void)ensureLayoutForCharacterRange:(NSRange)charRange

    Parameters

    charRange

    The character range for which layout is performed.

    Discussion

    The layout manager reserves the right to perform layout for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to perform layout for the specified glyph range, if it has not already done so.

    Declaration

    Swift

    func ensureLayoutForGlyphRange(_ glyphRange: NSRange)

    Objective-C

    - (void)ensureLayoutForGlyphRange:(NSRange)glyphRange

    Parameters

    glyphRange

    The glyph range for which layout is performed.

    Discussion

    The layout manager reserves the right to perform layout for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to perform layout for the specified text container, if it has not already done so.

    Declaration

    Swift

    func ensureLayoutForTextContainer(_ container: NSTextContainer)

    Objective-C

    - (void)ensureLayoutForTextContainer:(NSTextContainer *)container

    Parameters

    container

    The text container for which layout is performed.

    Discussion

    The layout manager reserves the right to perform layout for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Forces the receiver to perform layout for the specified area in the specified text container, if it has not already done so.

    Declaration

    Swift

    func ensureLayoutForBoundingRect(_ bounds: NSRect, inTextContainer container: NSTextContainer)

    Objective-C

    - (void)ensureLayoutForBoundingRect:(NSRect)bounds inTextContainer:(NSTextContainer *)container

    Parameters

    bounds

    The area for which layout is performed.

    container

    The text container containing the area for which layout is performed.

    Discussion

    The layout manager reserves the right to perform layout for larger ranges. If noncontiguous layout is disabled, then the affected range is always effectively extended to start at the beginning of the text.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Indicates whether the receiver uses the leading provided in the font.

    Declaration

    Swift

    var usesFontLeading: Bool

    Objective-C

    @property BOOL usesFontLeading

    Return Value

    YEStrue if the receiver uses the font’s leading; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Specifies whether or not the receiver uses the leading provided in the font.

    Declaration

    Swift

    var usesFontLeading: Bool

    Objective-C

    @property BOOL usesFontLeading

    Parameters

    flag

    If YEStrue, the receiver uses the font’s leading; if NOfalse, it does not.

    Discussion

    By default, a layout manager uses leading as specified by the font. However, this is not appropriate for most user-interface text, for which a fixed leading is usually specified by user-interface layout guidelines. This method enables the use of the font's leading to be turned off.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

    See Also

    – usesFontLeading
    setLineSpacing: (NSMutableParagraphStyle)

  • These glyph attribute constants are used only inside the glyph generation machinery, but they must be shared between components.

    Declaration

    Swift

    var NSGlyphAttributeSoft: Int { get } var NSGlyphAttributeElastic: Int { get } var NSGlyphAttributeBidiLevel: Int { get } var NSGlyphAttributeInscribe: Int { get }

    Objective-C

    enum { NSGlyphAttributeSoft = 0, NSGlyphAttributeElastic = 1, NSGlyphAttributeBidiLevel = 2, NSGlyphAttributeInscribe = 5 };

    Constants

    • NSGlyphAttributeSoft

      NSGlyphAttributeSoft

      The glyph is soft.

      Available in OS X v10.0 and later.

    • NSGlyphAttributeElastic

      NSGlyphAttributeElastic

      The glyph is elastic.

      Available in OS X v10.0 and later.

    • NSGlyphAttributeBidiLevel

      NSGlyphAttributeBidiLevel

      The bidirectional level (direction) of the glyph.

      Available in OS X v10.2 and later.

    • NSGlyphAttributeInscribe

      NSGlyphAttributeInscribe

      Glyph inscription attribute. See NSGlyphInscription for possible values.

      Available in OS X v10.0 and later.

  • Describes the text layout orientation.

    Declaration

    Swift

    enum NSTextLayoutOrientation : Int { case Horizontal case Vertical }

    Objective-C

    enum { NSTextLayoutOrientationHorizontal = 0, NSTextLayoutOrientationVertical = 1, }; typedef NSInteger NSTextLayoutOrientation;

    Constants

    • Horizontal

      NSTextLayoutOrientationHorizontal

      Lines rendered horizontally, extending from top to bottom

      Available in OS X v10.7 and later.

    • Vertical

      NSTextLayoutOrientationVertical

      Lines rendered vertically, extending from right to left

      Available in OS X v10.7 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • These constants specify how a glyph is laid out relative to the previous glyph. The glyph inscription constants are possible values for the glyph attribute NSGlyphAttributeInscribe. Glyph inscriptions are set during glyph generation.

    Declaration

    Swift

    enum NSGlyphInscription : UInt { case InscribeBase case InscribeBelow case InscribeAbove case InscribeOverstrike case InscribeOverBelow }

    Objective-C

    enum { NSGlyphInscribeBase = 0, NSGlyphInscribeBelow = 1, NSGlyphInscribeAbove = 2, NSGlyphInscribeOverstrike = 3, NSGlyphInscribeOverBelow = 4 }; typedef NSUInteger NSGlyphInscription;

    Constants

    • InscribeBase

      NSGlyphInscribeBase

      A base glyph; a character that the font can represent with a single glyph.

      Available in OS X v10.0 and later.

    • InscribeBelow

      NSGlyphInscribeBelow

      Glyph is rendered below the previous glyph.

      Available in OS X v10.0 and later.

    • InscribeAbove

      NSGlyphInscribeAbove

      Glyph is rendered above the previous glyph.

      Available in OS X v10.0 and later.

    • InscribeOverstrike

      NSGlyphInscribeOverstrike

      Glyph is rendered on top of the previous glyph.

      Available in OS X v10.0 and later.

    • InscribeOverBelow

      NSGlyphInscribeOverBelow

      Glyph is rendered on top and below the previous glyph.

      Available in OS X v10.0 and later.

    Discussion

    The only constants that the text system currently uses are NSGlyphInscribeBase (for most glyphs) and NSGlyphInscribeOverstrike (for nonbase glyphs). Nonbase glyphs occur when diacritical marks are applied to a base character, and the font does not have a single glyph to represent the combination.

    For example, if a font did not contain a single glyph for ü, but did contain separate glyphs for u and ¨, then it could be rendered with a base glyph u followed by a nonbase glyph ¨. In that case the nonbase glyph would have the value NSGlyphInscribeOverstrike for the inscribe attribute.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • These constants define the behavior of NSLayoutManager and NSTypesetter when laying out lines. They are used by setTypesetterBehavior: and typesetterBehavior to control the compatibility level of the typesetter.

    Declaration

    Swift

    enum NSTypesetterBehavior : Int { case LatestBehavior case OriginalBehavior case Behavior_10_2_WithCompatibility case Behavior_10_2 case Behavior_10_3 case Behavior_10_4 }

    Objective-C

    enum { NSTypesetterLatestBehavior = -1, NSTypesetterOriginalBehavior = 0, NSTypesetterBehavior_10_2_WithCompatibility = 1, NSTypesetterBehavior_10_2 = 2, NSTypesetterBehavior_10_3 = 3, NSTypesetterBehavior_10_4 = 4 }; typedef NSInteger NSTypesetterBehavior;

    Constants

    • LatestBehavior

      NSTypesetterLatestBehavior

      The most current typesetter behavior in the current system version.

      Available in OS X v10.2 and later.

    • OriginalBehavior

      NSTypesetterOriginalBehavior

      The original typesetter behavior, as shipped with OS X v10.1 and earlier.

      Available in OS X v10.2 and later.

    • Behavior_10_2_WithCompatibility

      NSTypesetterBehavior_10_2_WithCompatibility

      Typesetting same as NSTypesetterBehavior_10_2 but using line widths and height metric calculations that are the same as with NSTypesetterOriginalBehavior.

      Available in OS X v10.2 and later.

    • Behavior_10_2

      NSTypesetterBehavior_10_2

      The typesetter behavior introduced in OS X version 10.2. This typesetter behavior provides enhanced line and character spacing accuracy and supports more languages than the original typesetter behavior.

      Available in OS X v10.2 and later.

    • Behavior_10_3

      NSTypesetterBehavior_10_3

      The typesetter behavior introduced in OS X version 10.3.

      Available in OS X v10.3 and later.

    • Behavior_10_4

      NSTypesetterBehavior_10_4

      The typesetter behavior introduced in OS X version 10.4.

      Available in OS X v10.4 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.