Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Declared in | NSTypesetter.h |
Companion guides |
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
.
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.
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.
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.
+ printingAdjustmentInLayoutManager:forNominallySpacedGlyphRange:packedGlyphs:count:
– baselineOffsetInLayoutManager:glyphIndex:
– layoutManager
– setUsesFontLeading:
– usesFontLeading
– setTypesetterBehavior:
– typesetterBehavior
– setHyphenationFactor:
– hyphenationFactor
– currentParagraphStyle
– setAttributedString:
– attributedString
– setParagraphGlyphRange:separatorGlyphRange:
– paragraphGlyphRange
– paragraphSeparatorGlyphRange
– paragraphCharacterRange
– paragraphSeparatorCharacterRange
– attributesForExtraLineFragment
– layoutParagraphAtPoint:
– beginParagraph
– endParagraph
– beginLineWithGlyphAtIndex:
– endLineWithGlyphRange:
– lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:
– paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:
– paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:
– 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:
– 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:
Returns the default typesetter behavior.
+ (NSTypesetterBehavior)defaultTypesetterBehavior
The default typesetter behavior.
Possible return values are described in the “Constants” section for NSLayoutManager
.
NSTypesetter.h
Returns the interglyph spacing in the specified range when sent to a printer.
+ (NSSize)printingAdjustmentInLayoutManager:(NSLayoutManager *)layoutMgr forNominallySpacedGlyphRange:(NSRange)nominallySpacedGlyphsRange packedGlyphs:(const unsigned char *)packedGlyphs count:(NSUInteger)packedGlyphsCount
The layout manager that will do the drawing.
The range of the glyphs whose spacing is desired.
The glyphs as they are packed for sending to be drawn in layoutMgr.
The number of glyphs in packedGlyphs.
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.
NSTypesetter.h
Returns a shared instance of a reentrant typesetter.
+ (id)sharedSystemTypesetter
The shared system typesetter. This typesetter is reentrant.
NSTypesetter.h
Returns a shared instance of a reentrant typesetter that implements typesetting with the specified behavior.
+ (id)sharedSystemTypesetterForBehavior:(NSTypesetterBehavior)theBehavior
The desired behavior.
A shared instance of a reentrant typesetter that implements typesetting with the specified behavior.
Possible return values are described in the “Constants” section for NSLayoutManager
.
NSTypesetter.h
Returns the action associated with a control character.
- (NSTypesetterControlCharacterAction)actionForControlCharacterAtIndex:(NSUInteger)charIndex
The index of the control character.
The action associated with the control character at charIndex.
NSTypesetter.h
Returns the text backing store, usually an instance of NSTextStorage
.
- (NSAttributedString *)attributedString
The text backing store.
NSTypesetter.h
Returns the attributes used to lay out the extra line fragment.
- (NSDictionary *)attributesForExtraLineFragment
A dictionary of attributes used to lay out the extra line fragment.
The default implementation tries to use the NSTextView
method typingAttributes
if possible; otherwise, it uses the attributes for the last character.
NSTypesetter.h
Returns the distance from the bottom of the bounding box of a specified glyph to its baseline.
- (CGFloat)baselineOffsetInLayoutManager:(NSLayoutManager *)layoutMgr glyphIndex:(NSUInteger)glyphIndex
The layout manager used for the drawing.
The index of the glyph in question.
The distance from the bottom of the bounding box of the glyph in layoutMgr specified by glyphIndex to its baseline.
The text system uses this value to calculate the vertical position of underlines.
NSTypesetter.h
Sets up layout parameters at the beginning of a line during typesetting.
- (void)beginLineWithGlyphAtIndex:(NSUInteger)glyphIndex
The index of the first glyph to be laid out in the line.
Concrete subclass implementations of layoutParagraphAtPoint:
should invoke this method at the beginning of each line.
NSTypesetter.h
Sets up layout parameters at the beginning of a paragraph.
- (void)beginParagraph
Concrete subclasses should invoke this method at the beginning of their layoutParagraphAtPoint:
implementation.
NSTypesetter.h
Returns whether bidirectional text processing is enabled.
- (BOOL)bidiProcessingEnabled
YES
if bidirectional text processing is enabled, NO
otherwise.
NSTypesetter.h
Returns the bounding rectangle for the specified control glyph with the specified parameters.
- (NSRect)boundingBoxForControlGlyphAtIndex:(NSUInteger)glyphIndex forTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(NSRect)proposedRect glyphPosition:(NSPoint)glyphPosition characterIndex:(NSUInteger)charIndex
The index of the control glyph in question.
The text container to use to calculate the position.
The proposed line fragment rectangle.
The position of the glyph in textContainer.
The character index in textContainer.
The bounding rectangle of the control glyph at glyphIndex, at the given glyphPosition and character index charIndex, in textContainer.
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.
NSTypesetter.h
Returns the range for the characters in the receiver’s text store that are mapped to the specified glyphs.
- (NSRange)characterRangeForGlyphRange:(NSRange)glyphRange actualGlyphRange:(NSRangePointer)actualGlyphRange
The range of glyphs.
On return, the range of all glyphs mapped to the characters in the receiver’s text store. May be NULL
.
The range for the characters in the receiver’s text store that are mapped to the glyphs in glyphRange.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Returns the paragraph style object for the text being typeset.
- (NSParagraphStyle *)currentParagraphStyle
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:
.
NSTypesetter.h
Returns the text container for the text being typeset.
- (NSTextContainer *)currentTextContainer
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:
.
NSTypesetter.h
Deletes the specified glyphs from the glyph cache maintained by the layout manager.
- (void)deleteGlyphsInRange:(NSRange)glyphRange
The range of glyphs to be deleted.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Sets up layout parameters at the end of a line during typesetting.
- (void)endLineWithGlyphRange:(NSRange)lineGlyphRange
The range of glyphs laid out in the line.
Concrete subclass implementations of layoutParagraphAtPoint:
should invoke this method at the end of each line.
NSTypesetter.h
Sets up layout parameters at the end of a paragraph.
- (void)endParagraph
Concrete subclasses should invoke this method at the end of their layoutParagraphAtPoint:
implementation.
NSTypesetter.h
Extracts the information needed to lay out the provided glyphs from the provided range.
- (NSUInteger)getGlyphsInRange:(NSRange)glyphsRange glyphs:(NSGlyph *)glyphBuffer characterIndexes:(NSUInteger *)charIndexBuffer glyphInscriptions:(NSGlyphInscription *)inscribeBuffer elasticBits:(BOOL *)elasticBuffer bidiLevels:(unsigned char *)bidiLevelBuffer
The range of glyphs.
The glyphs to lay out.
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.
The inscription attributes for each glyph, which are used to layout characters that are combined together.
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.
Contains the bidirectional level value generated by NSGlyphGenerator
, in case a subclass chooses to use this value.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Calculates the line fragment rectangle and line fragment used rectangle for blank lines.
- (void)getLineFragmentRect:(NSRectPointer)lineFragmentRect usedRect:(NSRectPointer)lineFragmentUsedRect forParagraphSeparatorGlyphRange:(NSRange)paragraphSeparatorGlyphRange atProposedOrigin:(NSPoint)lineOrigin
On return, the calculated line fragment rectangle.
On return, the used rectangle (the portion of the line fragment rectangle that actually contains marks).
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).
The origin point of the line fragment rectangle.
NSTypesetter.h
Calculates line fragment rectangle, line fragment used rectangle, and remaining rectangle for a line fragment.
- (void)getLineFragmentRect:(NSRectPointer)lineFragmentRect usedRect:(NSRectPointer)lineFragmentUsedRect remainingRect:(NSRectPointer)remainingRect forStartingGlyphAtIndex:(NSUInteger)startingGlyphIndex proposedRect:(NSRect)proposedRect lineSpacing:(CGFloat)lineSpacing paragraphSpacingBefore:(CGFloat)paragraphSpacingBefore paragraphSpacingAfter:(CGFloat)paragraphSpacingAfter
On return, the calculated line fragment rectangle.
On return, the used rectangle (the portion of the line fragment rectangle that actually contains marks).
On return, the remaining rectangle of proposedRect.
The glyph index where the line fragment starts.
The proposed rectangle of the line fragment.
The line spacing.
The spacing before the paragraph.
The spacing after the paragraph.
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.
NSTypesetter.h
Returns the range for the glyphs mapped to the characters of the text store in the specified range.
- (NSRange)glyphRangeForCharacterRange:(NSRange)charRange actualCharacterRange:(NSRangePointer)actualCharRange
The range of the characters whose glyph range is desired.
On return, all characters mapped to those glyphs; may be NULL
.
The range for the glyphs mapped to the characters of the text store in charRange.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Returns the current hyphenation factor.
- (float)hyphenationFactor
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.
NSTypesetter.h
Returns the hyphenation factor in effect at a specified location.
- (float)hyphenationFactorForGlyphAtIndex:(NSUInteger)glyphIndex
The index of the glyph position to examine.
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.
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.
NSTypesetter.h
Returns the hyphen character to be inserted after the specified glyph.
- (UTF32Char)hyphenCharacterForGlyphAtIndex:(NSUInteger)glyphIndex
The index of the glyph in question.
The hyphen character to be inserted after the glyph at glyphIndex.
The typesetter calls this method before hyphenating. A subclass can override this method to return a different hyphen glyph.
NSTypesetter.h
Enables the typesetter to insert a new glyph into the stream.
- (void)insertGlyph:(NSGlyph)glyph atGlyphIndex:(NSUInteger)glyphIndex characterIndex:(NSUInteger)charIndex
The glyph to insert into the glyph cache.
The index at which to insert glyph.
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.
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.
NSTypesetter.h
Lays out glyphs in the specified layout manager starting at a specified glyph.
- (void)layoutGlyphsInLayoutManager:(NSLayoutManager *)layoutMgr startingAtGlyphIndex:(NSUInteger)startGlyphIndex maxNumberOfLineFragments:(NSUInteger)maxNumLines nextGlyphIndex:(NSUInteger *)nextGlyph
The layout manager in which to lay out glyphs.
The index of the starting glyph.
The maximum number of lines to generate. Fewer lines may be laid out if the glyph storage runs out of glyphs.
On return, set to the index of the next glyph that needs to be laid out.
NSTypesetter.h
Returns the layout manager for the text being typeset.
- (NSLayoutManager *)layoutManager
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:
.
NSTypesetter.h
Lays out glyphs in the current glyph range until the next paragraph separator is reached.
- (NSUInteger)layoutParagraphAtPoint:(NSPointPointer)lineFragmentOrigin
The upper-left corner of line fragment rectangle. On return, lineFragmentOrigin contains the next origin.
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.
Concrete subclasses must implement this method. A concrete implementation must invoke beginParagraph
, beginLineWithGlyphAtIndex:
, endLineWithGlyphRange:
, and endParagraph
.
NSTypesetter.h
Returns the current line fragment padding, in points.
- (CGFloat)lineFragmentPadding
The current line fragment padding, in points; that is, the portion on each end of the line fragment rectangle left blank.
Text is inset within the line fragment rectangle by this amount.
NSTypesetter.h
Returns the line spacing in effect following the specified glyph.
- (CGFloat)lineSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect
The index of the glyph in question.
The proposed line fragment rectangle.
the line spacing in effect following the glyph at glyphIndex.
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.
NSTypesetter.h
Returns the character range currently being processed.
- (NSRange)paragraphCharacterRange
The character range currently being processed.
NSTypesetter.h
Returns the glyph range currently being processed.
- (NSRange)paragraphGlyphRange
The glyph range currently being processed.
– setParagraphGlyphRange:separatorGlyphRange:
– paragraphSeparatorGlyphRange
– paragraphCharacterRange
– paragraphSeparatorCharacterRange
NSTypesetter.h
Returns the current paragraph separator character range.
- (NSRange)paragraphSeparatorCharacterRange
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.
NSTypesetter.h
Returns the current paragraph separator range.
- (NSRange)paragraphSeparatorGlyphRange
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.
– setParagraphGlyphRange:separatorGlyphRange:
– paragraphGlyphRange
– paragraphSeparatorCharacterRange
– paragraphCharacterRange
NSTypesetter.h
Returns the paragraph spacing that is in effect after the specified glyph.
- (CGFloat)paragraphSpacingAfterGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect
The index of the glyph in question.
The line fragment rectangle of the last line in the paragraph.
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.
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
.
NSTypesetter.h
Returns the number of points of space—added before a paragraph—that is in effect before the specified glyph.
- (CGFloat)paragraphSpacingBeforeGlyphAtIndex:(NSUInteger)glyphIndex withProposedLineFragmentRect:(NSRect)rect
The index of the glyph in question.
The line fragment rectangle of the first line in the paragraph.
The number of points of space—added before a paragraph—that is in effect before the glyph specified by glyphIndex.
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
.
NSTypesetter.h
Sets the size the specified glyphs (assumed to be attachments) will be asked to draw themselves at.
- (void)setAttachmentSize:(NSSize)attachmentSize forGlyphRange:(NSRange)glyphRange
The size the glyphs in glyphRange (assumed to be attachments) will be asked to draw themselves at.
The range of glyphs the attachment size applies to.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Sets the text backing store on which this typesetter operates.
- (void)setAttributedString:(NSAttributedString *)attrString
The text backing store on which the typesetter should operate.
Typesetters do not retain the text backing store on which they are operating.
NSTypesetter.h
Sets the direction of the specified glyphs for bidirectional text.
- (void)setBidiLevels:(const uint8_t *)levels forGlyphRange:(NSRange)glyphRange
Values in levels can range from 0 to 61 as defined by Unicode Standard Annex #9.
The range of glyphs for which the bidirectional text levels are desired.
A subclass can override this method to interact with custom glyph storage.
NSTypesetter.h
Controls whether the typesetter performs bidirectional text processing.
- (void)setBidiProcessingEnabled:(BOOL)flag
YES
to enable bidirectional text processing, NO
to disable it.
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.
NSTypesetter.h
Sets whether the specified glyphs exceed the bounds of the line fragment in which they are laid out.
- (void)setDrawsOutsideLineFragment:(BOOL)flag forGlyphRange:(NSRange)glyphRange
YES
if the glyphs in glyphRange exceed the bounds of the line fragment in which they are laid out, NO
otherwise.
The range of the glyphs in question.
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.
NSTypesetter.h
Sets whether to force the layout manager to invalidate the specified portion of the glyph cache when invalidating layout.
- (void)setHardInvalidation:(BOOL)flag forGlyphRange:(NSRange)glyphRange
YES
if the layout manager should invalidate the specified portion of the glyph cache, NO
otherwise.
The range of glyphs in the cache to be marked for hard invalidation.
NSTypesetter.h
Sets the threshold controlling when hyphenation is attempted.
- (void)setHyphenationFactor:(float)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.
NSTypesetter.h
Sets the amount (in points) by which text is inset within line fragment rectangles.
- (void)setLineFragmentPadding:(CGFloat)padding
The amount (in points) by which text is inset within line fragment rectangles.
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.
NSTypesetter.h
Sets the line fragment rectangle where the specified glyphs are laid out.
- (void)setLineFragmentRect:(NSRect)fragmentRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRect)usedRect baselineOffset:(CGFloat)baselineOffset
The line fragment rectangle where the glyphs in glyphRange are laid out.
The range of the specified glyphs.
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 vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.
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.
NSTypesetter.h
Sets the location where the specified glyphs are laid out.
- (void)setLocation:(NSPoint)location withAdvancements:(const CGFloat *)advancements forStartOfGlyphRange:(NSRange)glyphRange
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:
.
The nominal glyph advance width specified in the font metric information.
The range of glyphs whose layout location is being set. This series of glyphs 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.
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.
NSTypesetter.h
Sets whether the specified glyphs are not shown.
- (void)setNotShownAttribute:(BOOL)flag forGlyphRange:(NSRange)glyphRange
YES
if the glyphs in glyphRange are not shown, NO
if they are shown.
The range of glyphs in question.
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.
NSTypesetter.h
Sets the current glyph range being processed.
- (void)setParagraphGlyphRange:(NSRange)paragraphRange separatorGlyphRange:(NSRange)paragraphSeparatorRange
The current glyph range being processed.
The range of the paragraph separator character or characters.
NSTypesetter.h
Sets the default typesetter behavior, which affects glyph spacing and line height.
- (void)setTypesetterBehavior:(NSTypesetterBehavior)behavior
The new behavior.
NSTypesetter.h
Sets whether the typesetter uses the leading (or line gap) value specified in the font metric information.
- (void)setUsesFontLeading:(BOOL)flag
YES
to use the information in the font metrics, NO
to ignore it.
NSTypesetter.h
Returns whether the line being laid out should be broken by hyphenating at the specified character.
- (BOOL)shouldBreakLineByHyphenatingBeforeCharacterAtIndex:(NSUInteger)charIndex
The index of the character just after the proposed hyphenation would occur.
YES
if the line should be broken by hyphenating, NO
otherwise.
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.
NSTypesetter.h
Returns whether the line being laid out should be broken by a word break at the specified character.
- (BOOL)shouldBreakLineByWordBeforeCharacterAtIndex:(NSUInteger)charIndex
The index of the character just after the proposed word break would occur.
YES
if the line should be broken by a word break, NO
otherwise.
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.
NSTypesetter.h
Returns a screen font suitable for use in place of a given font.
- (NSFont *)substituteFontForFont:(NSFont *)originalFont
The original font.
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.
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.
NSTypesetter.h
Replaces the specified glyphs with specified replacement glyphs.
- (void)substituteGlyphsInRange:(NSRange)glyphRange withGlyphs:(NSGlyph *)glyphs
The range of glyphs to be substituted.
The glyphs to substitute for the glyphs in glyphRange
.
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.
NSTypesetter.h
Returns an array containing the text containers belonging to the current layout manager.
- (NSArray *)textContainers
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:
.
NSTypesetter.h
Returns the text tab next closest to a given glyph location within the given parameters.
- (NSTextTab *)textTabForGlyphLocation:(CGFloat)glyphLocation writingDirection:(NSWritingDirection)direction maxLocation:(CGFloat)maxLocation
The location at which to start searching.
The direction in which to search.
The maximum location for the search.
The text tab next closest to glyphLocation, indexing in direction but not beyond maxLocation.
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.
NSTypesetter.h
Returns the current typesetter behavior.
- (NSTypesetterBehavior)typesetterBehavior
The current typesetter behavior.
NSTypesetter.h
Returns whether the typesetter uses the leading (or line gap) value specified in the font metric information of the current font.
- (BOOL)usesFontLeading
YES
if it uses the information in the font metrics, NO
otherwise.
NSTypesetter.h
Called by the typesetter just prior to storing the actual line fragment rectangle location in the layout manager.
- (void)willSetLineFragmentRect:(NSRectPointer)lineRect forGlyphRange:(NSRange)glyphRange usedRect:(NSRectPointer)usedRect baselineOffset:(CGFloat *)baselineOffset
The rectangle in which the glyphs in glyphRange are laid out.
The range of the glyphs to lay out.
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 vertical distance in pixels from the line fragment origin to the baseline on which the glyphs align.
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).
NSTypesetter.h
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;
NSTypesetterZeroAdvancementAction
Glyphs with this action are flitered out from layout (notShownAttribute == YES)
.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetterWhitespaceAction
The width for glyphs with this action are determined by boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:
, if the method is implemented; otherwise, same as NSTypesetterZeroAdvancementAction
.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetterHorizontalTabAction
Treated as tab character.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetterLineBreakAction
Causes line break.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetterParagraphBreakAction
Causes paragraph break; the value returned by firstLineHeadIndent
is the advancement used for the following glyph.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetterContainerBreakAction
Causes container break.
Available in Mac OS X v10.4 and later.
Declared in NSTypesetter.h
.
NSTypesetter.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-26)