Mac Developer Library

Developer

AppKit Framework Reference NSATSTypesetter Class Reference

Options
Deployment Target:

On This Page
Language:

NSATSTypesetter

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.3 and later.

NSATSTypesetter is a concrete subclass of NSTypesetter that places glyphs during the text layout process. The typesetter creates line fragment rectangles, positions glyphs within the line fragments, determines line breaks by word wrapping and hyphenation, and handles tab positioning.

NSATSTypesetter encapsulates the advanced typesetting capabilities of Core Text. NSATSTypesetter provides enhanced line and character spacing accuracy and supports more languages, including bidirectional languages, than the original, built-in typesetter class NSSimpleHorizontalTypesetter (which is deprecated in OS X version 10.4 and later).

Subclassing Notes

NSATSTypesetter introduced a set of interfaces in OS X version 10.3 that facilitated subclassing and made it possible to substitute a custom layout engine into the Cocoa text system. In OS X version 10.4, those interfaces moved to NSTypesetter, which you can subclass to the same effect. See the NSTypesetter reference documentation for relevant subclassing notes.

  • Returns a shared instance of NSATSTypesetter.

    Declaration

    Swift

    class func sharedTypesetter() -> NSATSTypesetter

    Objective-C

    + (NSATSTypesetter *)sharedTypesetter

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the layout manager for the text being typeset.

    Declaration

    Objective-C

    - (NSLayoutManager *)layoutManager

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets a Boolean value controlling whether the typesetter uses the leading (or line gap) value specified in the font metric information.

    Declaration

    Objective-C

    - (void)setUsesFontLeading:(BOOL)flag

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the typesetter uses the leading (or line gap) value specified in the font metric information of the current font.

    Declaration

    Objective-C

    - (BOOL)usesFontLeading

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the default typesetter behavior, which affects glyph spacing and line height.

    Declaration

    Objective-C

    - (void)setTypesetterBehavior:(NSTypesetterBehavior)behavior

    Discussion

    The possible values for behavior are described in the Constants section of the NSLayoutManager reference.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the current typesetter behavior value.

    Declaration

    Objective-C

    - (NSTypesetterBehavior)typesetterBehavior

    Discussion

    The possible return values are described in the Constants section of the NSLayoutManager reference.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the threshold controlling when hyphenation is attempted

    Declaration

    Objective-C

    - (void)setHyphenationFactor:(float)factor

    Discussion

    The factor argument is in the range of 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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the current hyphenation factor.

    Declaration

    Objective-C

    - (float)hyphenationFactor

    Discussion

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

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the text container for the text being typeset.

    Declaration

    Objective-C

    - (NSTextContainer *)currentTextContainer

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the amount (in points) by which text is inset within line fragment rectangles

    Declaration

    Objective-C

    - (void)setLineFragmentPadding:(CGFloat)padding

    Discussion

    Note that line fragment padding isn’t a suitable means for expressing margins; you should set the NSTextView object’s position and size for document margins or the paragraph margin attributes for text margins.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the current line fragment padding amount; that is, the portion on each end of the line fragment rectangle left blank.

    Declaration

    Objective-C

    - (CGFloat)lineFragmentPadding

    Discussion

    Text is inset within the line fragment rectangle by this amount.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns a screen font suitable for use in place of the specified original font, or simply returns the original font if a screen font can’t be used or isn’t available.

    Declaration

    Swift

    func substituteFontForFont(_ originalFont: NSFont) -> NSFont

    Objective-C

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

    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.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the text tab next closest to a given glyph location, indexing in the specified direction but not beyond a given glyph location.

    Declaration

    Swift

    func textTabForGlyphLocation(_ glyphLocation: CGFloat, writingDirection direction: NSWritingDirection, maxLocation maxLocation: CGFloat) -> NSTextTab?

    Objective-C

    - (NSTextTab *)textTabForGlyphLocation:(CGFloat)glyphLocation writingDirection:(NSWritingDirection)direction maxLocation:(CGFloat)maxLocation

    Discussion

    The typesetter calls this method whenever it finds a tab character. To determine the width to advance the next glyph, the typesetter examines the NSParagraphStyle tab array and the default tab interval.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets a Boolean value controlling whether the typesetter performs bidirectional text processing.

    Declaration

    Objective-C

    - (void)setBidiProcessingEnabled:(BOOL)flag

    Discussion

    You can use this method to disable the bidirectional layout stage if you know the paragraph does not need this stage; that is, if the characters in the backing store are in display order.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns a Boolean value indicating the bidirectional text processing setting currently in effect.

    Declaration

    Objective-C

    - (BOOL)bidiProcessingEnabled

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Lays out glyphs in the current glyph range until the next paragraph separator is reached.

    Declaration

    Swift

    func layoutParagraphAtPoint(_ lineFragmentOrigin: UnsafeMutablePointer<NSPoint>) -> Int

    Objective-C

    - (NSUInteger)layoutParagraphAtPoint:(NSPoint *)lineFragmentOrigin

    Discussion

    The lineFragmentOrigin specifies the upper-left corner of line fragment rectangle. On return, lineFragmentOrigin contains the next origin. This method returns the next glyph index. Usually it’s the index right after the paragraph separator, but it can be inside the paragraph range if, for example, the end of the text container is reached before the paragraph separator.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the line spacing in effect following the specified glyph.

    Declaration

    Swift

    func lineSpacingAfterGlyphAtIndex(_ glyphIndex: Int, withProposedLineFragmentRect rect: NSRect) -> CGFloat

    Objective-C

    - (CGFloat)lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect

    Discussion

    The NSATSTypesetter calls this method to determine the number of points of space to include below the descenders in the used rectangle for the proposed line fragment rectangle rect.

    Line spacing, also called leading, is an attribute of NSParagraphStyle, which you can set on an NSMutableParagraphStyle object. A font typically includes a default minimum line spacing metric used if none is set in the paragraph style.

    If the typesetter behavior specified in the NSLayoutManager is NSTypesetterOriginalBehavior, the text system uses the original, private typesetter NSSimpleHorizontalTypesetter, which adds the line spacing above the ascender. Similarly, NSATSTypesetter adds the line spacing above the ascender if the value is negative.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the paragraph spacing, the number of points of space added following a paragraph, which is in effect after the specified glyph.

    Declaration

    Swift

    func paragraphSpacingAfterGlyphAtIndex(_ glyphIndex: Int, withProposedLineFragmentRect rect: NSRect) -> CGFloat

    Objective-C

    - (CGFloat)paragraphSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect

    Discussion

    The rect argument specifies the line fragment rectangle of the last line in the paragraph.

    The typesetter adds the number of points specified in the return value to the bottom of the line fragment rectangle specified by rect (but not to the used line fragment rectangle for that line). Paragraph spacing added after a paragraph correlates to the value returned by the paragraphSpacing method of NSParagraphStyle, which you can set using the setParagraphSpacing: method of NSMutableParagraphStyle.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the number of points of space added before a paragraph, which is in effect before the specified glyph.

    Declaration

    Swift

    func paragraphSpacingBeforeGlyphAtIndex(_ glyphIndex: Int, withProposedLineFragmentRect rect: NSRect) -> CGFloat

    Objective-C

    - (CGFloat)paragraphSpacingBeforeGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect

    Discussion

    The rect argument specifies the line fragment rectangle of the first line in the paragraph.

    The typesetter adds the number of points specified in the return value to the top of the line fragment rectangle specified by rect (but not to the used line fragment rectangle for that line). Paragraph spacing added before a paragraph correlates to the value returned by the paragraphSpacingBefore method of NSParagraphStyle, which you can set using the setParagraphSpacingBefore: method of NSMutableParagraphStyle.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets a Boolean value controlling whether to force the layout manager to invalidate the portion of the glyph cache in the given glyph range when invalidating layout.

    Declaration

    Swift

    func setHardInvalidation(_ flag: Bool, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setHardInvalidation:(BOOL)flag forGlyphRange:(NSRange)glyphRange

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the bounding rectangle for the given control glyph, at the given glyph position and character index, in the given text container.

    Declaration

    Swift

    func boundingBoxForControlGlyphAtIndex(_ glyphIndex: Int, forTextContainer textContainer: NSTextContainer, proposedLineFragment proposedRect: NSRect, glyphPosition glyphPosition: NSPoint, characterIndex charIndex: Int) -> NSRect

    Objective-C

    - (NSRect)boundingBoxForControlGlyphAtIndex:(NSUInteger)glyphIndex forTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(NSRect)proposedRect glyphPosition:(NSPoint)glyphPosition characterIndex:(NSUInteger)charIndex

    Discussion

    Returns the bounding rectangle for the control glyph at glyphIndex, at the given glyphPosition and character index charIndex, in textContainer. The proposed line fragment rectangle is specified by proposedRect.

    The typesetter calls this method when it encounters an NSControlGlyph. The default behavior is to return zero width for control glyphs. A subclass can override this method to do something different, such as implement a way to display control characters.

    NSGlyphGenerator can choose whether or not to map control characters to NSControlGlyph. Tab characters, for example, do not use this facility.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Calculates the line fragment rectangle and line fragment used rectangle for blank lines.

    Declaration

    Swift

    func getLineFragmentRect(_ lineFragmentRect: UnsafeMutablePointer<NSRect>, usedRect lineFragmentUsedRect: UnsafeMutablePointer<NSRect>, forParagraphSeparatorGlyphRange paragraphSeparatorGlyphRange: NSRange, atProposedOrigin lineOrigin: NSPoint)

    Objective-C

    - (void)getLineFragmentRect:(NSRect *)lineFragmentRect usedRect:(NSRect *)lineFragmentUsedRect forParagraphSeparatorGlyphRange:(NSRange)paragraphSeparatorGlyphRange atProposedOrigin:(NSPoint)lineOrigin

    Discussion

    The method returns the calculated line fragment rectangle in lineFragmentRect, and it returns the used rectangle (the portion of the line fragment rectangle that actually contains marks) in lineFragmentUsedRect. The paragraphSeparatorGlyphRange is the range of glyphs under consideration, and lineOrigin is the origin point of the line fragment rectangle. A paragraphSeparatorGlyphRange with length 0 indicates an extra line fragment (which occurs if the last character in the paragraph is a line separator.)

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the hyphen character to be inserted after the given glyph when hyphenation is enabled in the layout manager.

    Declaration

    Swift

    func hyphenCharacterForGlyphAtIndex(_ glyphIndex: Int) -> UTF32Char

    Objective-C

    - (UTF32Char)hyphenCharacterForGlyphAtIndex:(NSUInteger)glyphIndex

    Discussion

    The typesetter calls this method before hyphenating. A subclass can override this method to return a different hyphen glyph.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the hyphenation factor in effect at the given glyph index.

    Declaration

    Swift

    func hyphenationFactorForGlyphAtIndex(_ glyphIndex: Int) -> Float

    Objective-C

    - (float)hyphenationFactorForGlyphAtIndex:(NSUInteger)glyphIndex

    Discussion

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

    The typesetter calls this method with a proposed hyphenation point for a line break to find the hyphenation factor in effect at that time. A subclass can override this method to customize the text layout process.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • The typesetter calls this method, if implemented by a subclass, before breaking a line by hyphenating before the character at the given character index, enabling the subclass to control line breaking.

    Declaration

    Swift

    func shouldBreakLineByHyphenatingBeforeCharacterAtIndex(_ charIndex: Int) -> Bool

    Objective-C

    - (BOOL)shouldBreakLineByHyphenatingBeforeCharacterAtIndex:(NSUInteger)charIndex

    Discussion

    A subclass can override this method to customize the text layout process. If the method returns NOfalse, the typesetter continues looking for a break point.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • The typesetter calls this method, if implemented by a subclass, before breaking a line by word wrapping before the character at the given character index, enabling the subclass to control line breaking.

    Declaration

    Swift

    func shouldBreakLineByWordBeforeCharacterAtIndex(_ charIndex: Int) -> Bool

    Objective-C

    - (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:(NSUInteger)charIndex

    Discussion

    A subclass can override this method to customize the text layout process. If the method returns NOfalse, the typesetter continues looking for a break point.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Called by the typesetter just prior to calling setLineFragmentRect:forGlyphRange:usedRect:baselineOffset: which stores the actual line fragment rectangle location in the layout manager.

    Declaration

    Swift

    func willSetLineFragmentRect(_ lineRect: UnsafeMutablePointer<NSRect>, forGlyphRange glyphRange: NSRange, usedRect usedRect: UnsafeMutablePointer<NSRect>, baselineOffset baselineOffset: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)willSetLineFragmentRect:(NSRect *)lineRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRect *)usedRect baselineOffset:(CGFloat *)baselineOffset

    Discussion

    The lineRect argument is the rectangle in which the glyphs in glyphRange are laid out. The usedRect argument indicates the portion of lineRect, in the NSTextContainer object’s coordinate system, that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding). The usedRect must be equal to or contained within lineRect. The baselineOffset argument is the vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.

    A subclass can override this method to customize the text layout process. For example, it could change the shape of the line fragment rectangle. The subclass is responsible for ensuring that the modified rectangle remains valid (for example, that it lies within the text container).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the range for the characters in the receiver’s text store that are mapped to 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

    Discussion

    If actualGlyphRange is non-NULL, expands the requested range as needed so that it identifies all glyphs mapped to those characters and returns the new range by reference in actualGlyphRange.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Deletes the glyphs in the given glyph range from the glyph cache maintained by the layout manager.

    Declaration

    Swift

    func deleteGlyphsInRange(_ glyphRange: NSRange)

    Objective-C

    - (void)deleteGlyphsInRange:(NSRange)glyphRange

    Discussion

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Extracts the information needed to lay out the glyphs in the given glyph buffer from the given glyph range.

    Declaration

    Swift

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

    Objective-C

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

    Discussion

    The charIndexBuffer contains the original characters for the glyphs. 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.

    The inscribeBuffer contains the inscription attributes for each glyph, which are used to layout characters that are combined together. The possible values are described in the Constants section of the NSLayoutManager reference.

    The elasticBuffer contains a Boolean value 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.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Returns the range for the glyphs mapped to the characters of the text store in the given character range.

    Declaration

    Swift

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

    Objective-C

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

    Discussion

    If actualCharRange is non-NULL, expands the requested range as needed so that it identifies all characters mapped to those glyphs and returns the new range by reference in actualCharRange.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Enables the typesetter to insert a new glyph into the stream.

    Declaration

    Swift

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

    Objective-C

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

    Discussion

    Inserts glyph into the glyph cache at glyphIndex and maps it to the character at charIndex. If the glyph is mapped to several characters, charIndex should indicate the first character to which it’s mapped.

    The standard typesetter uses this method for inserting hyphenation glyphs. Because this method keeps the glyph caches synchronized, subclasses should always use this method to insert glyphs instead of calling layoutManager directly.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Declaration

    Objective-C

    - (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect remainingRect:(NSRectPointer)remainingRect

    Discussion

    Returns the largest rectangle available for the proposed rectangle proposedRect. It also returns a rectangle in remainingRect containing any remaining space, such as that left on the other side of a hole or gap in the text container.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.3 and later.

    Deprecated in OS X v10.4.

  • Sets the size the glyphs in the given glyph range (assumed to be attachments) will be asked to draw themselves.

    Declaration

    Swift

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

    Objective-C

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

    Discussion

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the direction of the glyphs in the given glyph range for bidirectional text to the given levels.

    Declaration

    Swift

    func setBidiLevels(_ levels: UnsafePointer<UInt8>, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setBidiLevels:(const uint8_t *)levels forGlyphRange:(NSRange)glyphRange

    Discussion

    The value of levels can range from 0 to 61 as defined by Unicode Standard Annex #9.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets a Boolean value controlling whether the glyphs in the given glyph range exceed the bounds of the line fragment in which they are laid out.

    Declaration

    Swift

    func setDrawsOutsideLineFragment(_ flag: Bool, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setDrawsOutsideLineFragment:(BOOL)flag forGlyphRange:(NSRange)glyphRange

    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.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the line fragment rectangle where the glyphs in in the given glyph range are laid out to the given line fragment rectangle.

    Declaration

    Swift

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

    Objective-C

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

    Discussion

    The exact positions of the glyphs must be set after the line fragment rectangle with setLocation:forStartOfGlyphRange:.

    The usedRect argument indicates the portion of fragmentRect, in the NSTextContainer object’s coordinate system, that actually contains glyphs or other marks that are drawn (including the text container’s line fragment padding). The usedRect must be equal to or contained within fragmentRect. The baselineOffset argument is the vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets the location where the glyphs in the given glyph range are laid out to the specified location.

    Declaration

    Swift

    func setLocation(_ location: NSPoint, withAdvancements advancements: UnsafePointer<CGFloat>, forStartOfGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setLocation:(NSPoint)location withAdvancements:(const CGFloat *)advancements forStartOfGlyphRange:(NSRange)glyphRange

    Discussion

    The x-coordinate of location is expressed relative to the line fragment rectangle origin, and the y-coordinate is expressed relative to the baseline previously specified by setLineFragmentRect:forGlyphRange:usedRect:baselineOffset:. The glyphRange defines a series of glyphs that can be displayed with a single PostScript show operation (a nominal range). Setting the location for a series of glyphs implies that the glyphs preceding it can’t be included in a single show operation. The advancements argument is the nominal glyph advance width specified in the font metric information.

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

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Sets a Boolean value controlling whether the glyphs in the given glyph rangeare not shown.

    Declaration

    Swift

    func setNotShownAttribute(_ flag: Bool, forGlyphRange glyphRange: NSRange)

    Objective-C

    - (void)setNotShownAttribute:(BOOL)flag forGlyphRange:(NSRange)glyphRange

    Discussion

    For example, a tab or newline character doesn’t leave any marks; it just indicates where following glyphs are laid out.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3. Moved to NSTypesetter in OS X v10.4 and later.

  • Replaces the glyphs in the given glyph range with the given glyphs.

    Declaration

    Swift

    func substituteGlyphsInRange(_ glyphRange: NSRange, withGlyphs glyphs: UnsafeMutablePointer<NSGlyph>)

    Objective-C

    - (void)substituteGlyphsInRange:(NSRange)glyphRange withGlyphs:(NSGlyph *)glyphs

    Discussion

    This method does not alter the glyph-to-character mapping or invalidate layout information.

    A subclass can override this method to interact with custom glyph storage.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.