NSTypesetter Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSTypesetter.h |
| Companion guides |
Overview
NSLayoutManager uses concrete subclasses of this abstract class, NSTypesetter, to perform line layout, which includes word wrapping, hyphenation, and line breaking in either vertical or horizontal rectangles. By default, the text system uses the concrete subclass NSATSTypesetter.
Subclassing Notes
NSTypesetter provides concrete subclasses with default implementation interfacing with the Cocoa text system. By subclassing NSTypesetter, an application can override the layoutParagraphAtPoint: method to integrate a custom typesetting engine into the Cocoa text system. On the other hand, an application can subclass NSATSTypesetter and override the glyph storage interface to integrate the concrete subclass into its own custom layout system.
NSTypesetter methods belong to three categories: glyph storage interface methods, layout phase interface methods, and core typesetter methods. The glyph storage interface methods map to NSLayoutManager methods. The typesetter itself calls these methods, and their default implementations call the Cocoa layout manager. An NSTypesetter subclass can override these methods to call its own glyph storage facility, in which case it should override all of them. (This does not preclude the overridden method calling its superclass implementation if appropriate.)
The layout phase interface provides control points similar to delegate methods; if implemented, the system invokes these methods to notify an NSTypesetter subclass of events in the layout process so it can intervene as needed.
The remainder of the NSTypesetter methods are primitive, core typesetter methods. The core typesetter methods correlate with typesetting state attributes; the layout manager calls these methods to store its values before starting the layout process. If you subclass NSTypesetter and override the glyph storage interface methods, you can call the core methods to control the typesetter directly.
Glyph Storage Interface
Override these methods to use NSTypesetter’s built-in concrete subclass, NSATSTypesetter, with a custom glyph storage and layout system other than the Cocoa layout manager and text container mechanism.
Layout Phase Interface
Override these methods to customize the text layout process, including modifying line fragments, controlling line breaking and hyphenation, and controlling the behavior of tabs and other control glyphs.
Tasks
Getting a Typesetter
Getting Information About a Typesetter
Getting Information About Glyphs
-
+ printingAdjustmentInLayoutManager:forNominallySpacedGlyphRange:packedGlyphs:count: -
– baselineOffsetInLayoutManager:glyphIndex:
Managing the Layout Manager
-
– layoutManager -
– setUsesFontLeading: -
– usesFontLeading -
– setTypesetterBehavior: -
– typesetterBehavior -
– setHyphenationFactor: -
– hyphenationFactor
Managing Text Containers
Mapping Screen and Printer Fonts
Handling Control Characters
Bidirectional Text Processing
Accessing Paragraph Typesetting Information
-
– currentParagraphStyle -
– setAttributedString: -
– attributedString -
– setParagraphGlyphRange:separatorGlyphRange: -
– paragraphGlyphRange -
– paragraphSeparatorGlyphRange -
– paragraphCharacterRange -
– paragraphSeparatorCharacterRange -
– attributesForExtraLineFragment
Paragraph Layout
-
– layoutParagraphAtPoint: -
– beginParagraph -
– endParagraph -
– beginLineWithGlyphAtIndex: -
– endLineWithGlyphRange:
Character Layout
Line and Paragraph Spacing
-
– lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect: -
– paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect: -
– paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:
Glyph Caching
Laying out Glyphs
-
– layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex: -
– boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex: -
– getLineFragmentRect:usedRect:forParagraphSeparatorGlyphRange:atProposedOrigin: -
– getLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter: -
– hyphenCharacterForGlyphAtIndex: -
– hyphenationFactorForGlyphAtIndex: -
– shouldBreakLineByHyphenatingBeforeCharacterAtIndex: -
– shouldBreakLineByWordBeforeCharacterAtIndex: -
– willSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:
Interfacing with Glyph Storage
-
– characterRangeForGlyphRange:actualGlyphRange: -
– deleteGlyphsInRange: -
– substituteGlyphsInRange:withGlyphs: -
– getGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels: -
– glyphRangeForCharacterRange:actualCharacterRange: -
– insertGlyph:atGlyphIndex:characterIndex: -
– setAttachmentSize:forGlyphRange: -
– setBidiLevels:forGlyphRange: -
– setDrawsOutsideLineFragment:forGlyphRange: -
– setLineFragmentRect:forGlyphRange:usedRect:baselineOffset: -
– setLocation:withAdvancements:forStartOfGlyphRange: -
– setNotShownAttribute:forGlyphRange:
Class Methods
defaultTypesetterBehavior
Returns the default typesetter behavior.
Return Value
The default typesetter behavior.
Discussion
Possible return values are described in the NSTypesetterBehavior section for NSLayoutManager.
Availability
- Available in OS X v10.2 and later.
Declared In
NSTypesetter.hprintingAdjustmentInLayoutManager:forNominallySpacedGlyphRange:packedGlyphs:count:
Returns the interglyph spacing in the specified range when sent to a printer.
Parameters
- layoutMgr
The layout manager that will do the drawing.
- nominallySpacedGlyphsRange
The range of the glyphs whose spacing is desired.
- packedGlyphs
The glyphs as they are packed for sending to be drawn in layoutMgr.
- packedGlyphsCount
The number of glyphs in packedGlyphs.
Return Value
The interglyph spacing in the specified range when sent to a printer. If the font metrics of the font used for displaying text on the screen is different from the font metrics of the font used in printing, then this interglyph spacing may need to be adjusted slightly to match that used on the screen.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTypesetter.hsharedSystemTypesetter
Returns a shared instance of a reentrant typesetter.
Return Value
The shared system typesetter. This typesetter is reentrant.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTypesetter.hsharedSystemTypesetterForBehavior:
Returns a shared instance of a reentrant typesetter that implements typesetting with the specified behavior.
Parameters
- theBehavior
The desired behavior.
Return Value
A shared instance of a reentrant typesetter that implements typesetting with the specified behavior.
Discussion
Possible return values are described in the NSTypesetterBehavior section for NSLayoutManager.
Availability
- Available in OS X v10.2 and later.
Declared In
NSTypesetter.hInstance Methods
actionForControlCharacterAtIndex:
Returns the action associated with a control character.
Parameters
- charIndex
The index of the control character.
Return Value
The action associated with the control character at charIndex.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hattributedString
Returns the text backing store, usually an instance of NSTextStorage.
Return Value
The text backing store.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hattributesForExtraLineFragment
Returns the attributes used to lay out the extra line fragment.
Return Value
A dictionary of attributes used to lay out the extra line fragment.
Discussion
The default implementation tries to use the NSTextView method typingAttributes if possible; otherwise, it uses the attributes for the last character.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hbaselineOffsetInLayoutManager:glyphIndex:
Returns the distance from the bottom of the line fragment rectangle in which the glyph resides to the glyph baseline.
Parameters
- layoutMgr
The layout manager used for the drawing.
- glyphIndex
The index of the glyph in question.
Return Value
The distance from the bottom of the line fragment rectangle in which the glyph resides to the glyph baseline.
Discussion
The text system uses this value to calculate the vertical position of underlines.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTypesetter.hbeginLineWithGlyphAtIndex:
Sets up layout parameters at the beginning of a line during typesetting.
Parameters
- glyphIndex
The index of the first glyph to be laid out in the line.
Discussion
Concrete subclass implementations of layoutParagraphAtPoint: should invoke this method at the beginning of each line.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hbeginParagraph
Sets up layout parameters at the beginning of a paragraph.
Discussion
Concrete subclasses should invoke this method at the beginning of their layoutParagraphAtPoint: implementation.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hbidiProcessingEnabled
Returns whether bidirectional text processing is enabled.
Return Value
YES if bidirectional text processing is enabled, NO otherwise.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hboundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:
Returns the bounding rectangle for the specified control glyph with the specified parameters.
Parameters
- glyphIndex
The index of the control glyph in question.
- textContainer
The text container to use to calculate the position.
- proposedRect
The proposed line fragment rectangle.
- glyphPosition
The position of the glyph in textContainer.
- charIndex
The character index in textContainer.
Return Value
The bounding rectangle of the control glyph at glyphIndex, at the given glyphPosition and character index charIndex, in textContainer.
Discussion
The typesetter calls this method when it encounters a control glyph. 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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hcharacterRangeForGlyphRange:actualGlyphRange:
Returns the range for the characters in the receiver’s text store that are mapped to the specified glyphs.
Parameters
- glyphRange
The range of glyphs.
- actualGlyphRange
On return, the range of all glyphs mapped to the characters in the receiver’s text store. May be
NULL.
Return Value
The range for the characters in the receiver’s text store that are mapped to the glyphs in glyphRange.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hcurrentParagraphStyle
Returns the paragraph style object for the text being typeset.
Return Value
The paragraph style object for the text being typeset. This value is valid only while the typesetter is performing layout. More specifically, it’s valid only when called inside layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hcurrentTextContainer
Returns the text container for the text being typeset.
Return Value
The text container for the text being typeset. This value is valid only while the typesetter is performing layout. More specifically, it’s valid only when called inside layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hdeleteGlyphsInRange:
Deletes the specified glyphs from the glyph cache maintained by the layout manager.
Parameters
- glyphRange
The range of glyphs to be deleted.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hendLineWithGlyphRange:
Sets up layout parameters at the end of a line during typesetting.
Parameters
- lineGlyphRange
The range of glyphs laid out in the line.
Discussion
Concrete subclass implementations of layoutParagraphAtPoint: should invoke this method at the end of each line.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hendParagraph
Sets up layout parameters at the end of a paragraph.
Discussion
Concrete subclasses should invoke this method at the end of their layoutParagraphAtPoint: implementation.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hgetGlyphsInRange:glyphs:characterIndexes:glyphInscriptions:elasticBits:bidiLevels:
Extracts the information needed to lay out the provided glyphs from the provided range.
Parameters
- glyphsRange
The range of glyphs.
- glyphBuffer
The glyphs to lay out.
- charIndexBuffer
The original characters for the glyphs. Note that a glyph at index 1 is not necessarily mapped to the character at index 1, because a glyph may be for a ligature or accent.
- inscribeBuffer
The inscription attributes for each glyph, which are used to layout characters that are combined together.
- 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.
- bidiLevelBuffer
Contains the bidirectional level value generated by
NSGlyphGenerator, in case a subclass chooses to use this value.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hgetLineFragmentRect:usedRect:forParagraphSeparatorGlyphRange:atProposedOrigin:
Calculates the line fragment rectangle and line fragment used rectangle for blank lines.
Parameters
- lineFragmentRect
On return, the calculated line fragment rectangle.
- lineFragmentUsedRect
On return, the used rectangle (the portion of the line fragment rectangle that actually contains marks).
- paragraphSeparatorGlyphRange
The range of glyphs under consideration. A paragraphSeparatorGlyphRange with length 0 indicates an extra line fragment (which occurs if the last character in the paragraph is a line separator).
- lineOrigin
The origin point of the line fragment rectangle.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hgetLineFragmentRect:usedRect:remainingRect:forStartingGlyphAtIndex:proposedRect:lineSpacing:paragraphSpacingBefore:paragraphSpacingAfter:
Calculates line fragment rectangle, line fragment used rectangle, and remaining rectangle for a line fragment.
Parameters
- lineFragmentRect
On return, the calculated line fragment rectangle.
- lineFragmentUsedRect
On return, the used rectangle (the portion of the line fragment rectangle that actually contains marks).
- remainingRect
On return, the remaining rectangle of proposedRect.
- startingGlyphIndex
The glyph index where the line fragment starts.
- proposedRect
The proposed rectangle of the line fragment.
- lineSpacing
The line spacing.
- paragraphSpacingBefore
The spacing before the paragraph.
- paragraphSpacingAfter
The spacing after the paragraph.
Discussion
The height of the line fragment is determined using lineSpacing, paragraphSpacingBefore, and paragraphSpacingAfter as well as proposedRect. The width for lineFragmentUsedRect is set to the lineFragmentRect width. In the standard implementation, paragraph spacing is included in the line fragment rectangle but not the line fragment used rectangle; line spacing is included in both.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hglyphRangeForCharacterRange:actualCharacterRange:
Returns the range for the glyphs mapped to the characters of the text store in the specified range.
Parameters
- charRange
The range of the characters whose glyph range is desired.
- actualCharRange
On return, all characters mapped to those glyphs; may be
NULL.
Return Value
The range for the glyphs mapped to the characters of the text store in charRange.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hhyphenationFactor
Returns the current hyphenation factor.
Return Value
The hyphenation factor, 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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hhyphenationFactorForGlyphAtIndex:
Returns the hyphenation factor in effect at a specified location.
Parameters
- glyphIndex
The index of the glyph position to examine.
Return Value
The hyphenation factor in effect at glyphIndex. 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.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hhyphenCharacterForGlyphAtIndex:
Returns the hyphen character to be inserted after the specified glyph.
Parameters
- glyphIndex
The index of the glyph in question.
Return Value
The hyphen character to be inserted after the glyph at glyphIndex.
Discussion
The typesetter calls this method before hyphenating. A subclass can override this method to return a different hyphen glyph.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hinsertGlyph:atGlyphIndex:characterIndex:
Enables the typesetter to insert a new glyph into the stream.
Parameters
- glyph
The glyph to insert into the glyph cache.
- glyphIndex
The index at which to insert glyph.
- charIndex
The index of the character that glyph maps to. If the glyph is mapped to several characters, charIndex should indicate the first character to which it’s mapped.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hlayoutCharactersInRange:forLayoutManager:maximumNumberOfLineFragments:
Lays out characters in the given character range for the specified layout manager.
Parameters
- characterRange
The range of the characters to lay out.
- layoutManager
The layout manager that does the drawing.
- maxNumLines
The maximum number of line fragments to lay out. Specify
NSUIntegerMaxfor unlimited number of line fragments.
Return Value
The method returns the actual character range that the receiving NSTypesetter processed.
Discussion
The layout process can be interrupted when the number of line fragments exceeds maxNumLines.
Availability
- Available in OS X v10.5 and later.
Declared In
NSTypesetter.hlayoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:
Lays out glyphs in the specified layout manager starting at a specified glyph.
Parameters
- layoutMgr
The layout manager in which to lay out glyphs.
- startGlyphIndex
The index of the starting glyph.
- maxNumLines
The maximum number of lines to generate. Fewer lines may be laid out if the glyph storage runs out of glyphs.
- nextGlyph
On return, set to the index of the next glyph that needs to be laid out.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTypesetter.hlayoutManager
Returns the layout manager for the text being typeset.
Return Value
The layout manager for the text being typeset. This value is valid only while the typesetter is performing layout. More specifically, it’s valid only when called inside layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hlayoutParagraphAtPoint:
Lays out glyphs in the current glyph range until the next paragraph separator is reached.
Parameters
- lineFragmentOrigin
The upper-left corner of line fragment rectangle. On return, lineFragmentOrigin contains the next origin.
Return Value
The next glyph index; usually 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.
Discussion
Concrete subclasses must implement this method. A concrete implementation must invoke beginParagraph, beginLineWithGlyphAtIndex:, endLineWithGlyphRange:, and endParagraph.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hlineFragmentPadding
Returns the current line fragment padding, in points.
Return Value
The current line fragment padding, in points; that is, the portion on each end of the line fragment rectangle left blank.
Discussion
Text is inset within the line fragment rectangle by this amount.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hlineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:
Returns the line spacing in effect following the specified glyph.
Parameters
- glyphIndex
The index of the glyph in question.
- rect
The proposed line fragment rectangle.
Return Value
the line spacing in effect following the glyph at glyphIndex.
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 layout manager 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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hparagraphCharacterRange
Returns the character range currently being processed.
Return Value
The character range currently being processed.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hparagraphGlyphRange
Returns the glyph range currently being processed.
Return Value
The glyph range currently being processed.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hparagraphSeparatorCharacterRange
Returns the current paragraph separator character range.
Return Value
The current paragraph separator character range, which is the full range that contains the current character range and that extends from one paragraph separator character to the next.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hparagraphSeparatorGlyphRange
Returns the current paragraph separator range.
Return Value
The current paragraph separator range, which is the full range that contains the current glyph range and that extends from one paragraph separator character to the next.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hparagraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:
Returns the paragraph spacing that is in effect after the specified glyph.
Parameters
- glyphIndex
The index of the glyph in question.
- rect
The line fragment rectangle of the last line in the paragraph.
Return Value
The paragraph spacing—that is, the number of points of space added following a paragraph—that is in effect after the glyph specified by glyphIndex.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hparagraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:
Returns the number of points of space—added before a paragraph—that is in effect before the specified glyph.
Parameters
- glyphIndex
The index of the glyph in question.
- rect
The line fragment rectangle of the first line in the paragraph.
Return Value
The number of points of space—added before a paragraph—that is in effect before the glyph specified by glyphIndex.
Discussion
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetAttachmentSize:forGlyphRange:
Sets the size the specified glyphs (assumed to be attachments) will be asked to draw themselves at.
Parameters
- attachmentSize
The size the glyphs in glyphRange (assumed to be attachments) will be asked to draw themselves at.
- glyphRange
The range of glyphs the attachment size applies to.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetAttributedString:
Sets the text backing store on which this typesetter operates.
Parameters
- attrString
The text backing store on which the typesetter should operate.
Special Considerations
Typesetters do not retain the text backing store on which they are operating.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hsetBidiLevels:forGlyphRange:
Sets the direction of the specified glyphs for bidirectional text.
Parameters
- levels
Values in levels can range from 0 to 61 as defined by Unicode Standard Annex #9.
- glyphRange
The range of glyphs for which the bidirectional text levels are desired.
Discussion
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetBidiProcessingEnabled:
Controls whether the typesetter performs bidirectional text processing.
Parameters
- flag
YESto enable bidirectional text processing,NOto disable it.
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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hsetDrawsOutsideLineFragment:forGlyphRange:
Sets whether the specified glyphs exceed the bounds of the line fragment in which they are laid out.
Parameters
- flag
YESif the glyphs in glyphRange exceed the bounds of the line fragment in which they are laid out,NOotherwise.- glyphRange
The range of the glyphs in question.
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetHardInvalidation:forGlyphRange:
Sets whether to force the layout manager to invalidate the specified portion of the glyph cache when invalidating layout.
Parameters
- flag
YESif the layout manager should invalidate the specified portion of the glyph cache,NOotherwise.- glyphRange
The range of glyphs in the cache to be marked for hard invalidation.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetHyphenationFactor:
Sets the threshold controlling when hyphenation is attempted.
Parameters
- factor
A frequency factor 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.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hsetLineFragmentPadding:
Sets the amount (in points) by which text is inset within line fragment rectangles.
Parameters
- padding
The amount (in points) by which text is inset within line fragment rectangles.
Special Considerations
Line fragment padding isn’t a suitable means for expressing margins; you should set the text view's position and size for document margins or the paragraph margin attributes for text margins.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hsetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:
Sets the line fragment rectangle where the specified glyphs are laid out.
Parameters
- fragmentRect
The line fragment rectangle where the glyphs in glyphRange are laid out.
- glyphRange
The range of the specified glyphs.
- usedRect
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.
- baselineOffset
The vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.
Discussion
The exact positions of the glyphs must be set after the line fragment rectangle with setLocation:forStartOfGlyphRange:.
A subclass can override this method to interact with custom glyph storage.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetLocation:withAdvancements:forStartOfGlyphRange:
Sets the location where the specified glyphs are laid out.
Parameters
- location
The location where the glyphs in glyphRange are laid out. 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:.- advancements
The nominal glyph advance width specified in the font metric information.
- glyphRange
The range of glyphs whose layout location is being set. This series of glyphs can be displayed with a single PostScript
showoperation (a nominal range).
Discussion
Setting the location for a series of glyphs implies that the glyphs preceding it can’t be included in a single show operation.
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetNotShownAttribute:forGlyphRange:
Sets whether the specified glyphs are not shown.
Parameters
- flag
YESif the glyphs in glyphRange are not shown,NOif they are shown.- glyphRange
The range of glyphs in question.
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetParagraphGlyphRange:separatorGlyphRange:
Sets the current glyph range being processed.
Parameters
- paragraphRange
The current glyph range being processed.
- paragraphSeparatorRange
The range of the paragraph separator character or characters.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsetTypesetterBehavior:
Sets the default typesetter behavior, which affects glyph spacing and line height.
Parameters
- behavior
The new behavior.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hsetUsesFontLeading:
Sets whether the typesetter uses the leading (or line gap) value specified in the font metric information.
Parameters
- flag
YESto use the information in the font metrics,NOto ignore it.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hshouldBreakLineByHyphenatingBeforeCharacterAtIndex:
Returns whether the line being laid out should be broken by hyphenating at the specified character.
Parameters
- charIndex
The index of the character just after the proposed hyphenation would occur.
Return Value
YES if the line should be broken by hyphenating, NO otherwise.
Discussion
The typesetter calls this method, if implemented by a subclass, before breaking a line by hyphenating before the character at charIndex, enabling the subclass to control line breaking.
A subclass can override this method to customize the text layout process. If the method returns NO, the typesetter continues looking for a break point.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hshouldBreakLineByWordBeforeCharacterAtIndex:
Returns whether the line being laid out should be broken by a word break at the specified character.
Parameters
- charIndex
The index of the character just after the proposed word break would occur.
Return Value
YES if the line should be broken by a word break, NO otherwise.
Discussion
The typesetter calls this method, if implemented by a subclass, before breaking a line by word wrapping before the character at charIndex, enabling the subclass to control line breaking.
A subclass can override this method to customize the text layout process. If the method returns NO, the typesetter continues looking for a break point.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsubstituteFontForFont:
Returns a screen font suitable for use in place of a given font.
Parameters
- originalFont
The original font.
Return Value
A screen font suitable for use in place of originalFont. This method returns originalFont if a screen font can’t be used or isn’t available.
Discussion
A screen font can only be substituted if the receiver is set to use screen fonts and if no text view associated with the receiver is scaled or rotated.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hsubstituteGlyphsInRange:withGlyphs:
Replaces the specified glyphs with specified replacement glyphs.
Parameters
- glyphRange
The range of glyphs to be substituted.
- glyphs
The glyphs to substitute for the glyphs in
glyphRange.
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.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.htextContainers
Returns an array containing the text containers belonging to the current layout manager.
Return Value
An array containing the text containers belonging to the current layout manager. This value is valid only while the typesetter is performing layout. More specifically, it’s valid only when called inside layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:nextGlyphIndex:.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.htextTabForGlyphLocation:writingDirection:maxLocation:
Returns the text tab next closest to a given glyph location within the given parameters.
Parameters
- glyphLocation
The location at which to start searching.
- direction
The direction in which to search.
- maxLocation
The maximum location for the search.
Return Value
The text tab next closest to glyphLocation, indexing in direction but not beyond 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 object's tab array and the default tab interval.
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.htypesetterBehavior
Returns the current typesetter behavior.
Return Value
The current typesetter behavior.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.husesFontLeading
Returns whether the typesetter uses the leading (or line gap) value specified in the font metric information of the current font.
Return Value
YES if it uses the information in the font metrics, NO otherwise.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSTypesetter.hwillSetLineFragmentRect:forGlyphRange:usedRect:baselineOffset:
Called by the typesetter just prior to storing the actual line fragment rectangle location in the layout manager.
Parameters
- lineRect
The rectangle in which the glyphs in glyphRange are laid out.
- glyphRange
The range of the glyphs to lay out.
- usedRect
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.
- baselineOffset
The vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.
Discussion
Called by the typesetter just prior to calling setLineFragmentRect:forGlyphRange:usedRect:baselineOffset: which stores the actual line fragment rectangle location in the layout manager.
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).
Availability
- Available in OS X v10.4 and later.
Declared In
NSTypesetter.hConstants
NSTypesetterControlCharacterAction
The following constants are possible values returned by the actionForControlCharacterAtIndex: method to determine the action associated with a control character.
enum {
NSTypesetterZeroAdvancementAction = (1 << 0),
NSTypesetterWhitespaceAction = (1 << 1),
NSTypesetterHorizontalTabAction = (1 << 2),
NSTypesetterLineBreakAction = (1 << 3),
NSTypesetterParagraphBreakAction = (1 << 4),
NSTypesetterContainerBreakAction = (1 << 5)
};
typedef NSUInteger NSTypesetterControlCharacterAction;
Constants
NSTypesetterZeroAdvancementActionGlyphs with this action are filtered out from layout
(notShownAttribute == YES).Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.NSTypesetterWhitespaceActionThe width for glyphs with this action are determined by
boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:, if the method is implemented; otherwise, same asNSTypesetterZeroAdvancementAction.Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.NSTypesetterHorizontalTabActionTreated as tab character.
Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.NSTypesetterLineBreakActionCauses line break.
Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.NSTypesetterParagraphBreakActionCauses paragraph break; the value returned by
firstLineHeadIndentis the advancement used for the following glyph.Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.NSTypesetterContainerBreakActionCauses container break.
Available in OS X v10.4 and later.
Declared in
NSTypesetter.h.
© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-06-11)