|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||Cocoa||MBS MacCocoa Plugin||12.1||Yes||No||No||Yes, macOS only||No|
It maps Unicode character codes to glyphs, sets the glyphs in a series of NSTextContainer objects, and displays them in a series of NSTextView objects. In addition to its core function of laying out text, an NSLayoutManager object coordinates its NSTextView objects, provides services to those text views to support NSRulerView instances for editing paragraph styles, and handles the layout and display of text attributes not inherent in glyphs (such as underline or strikethrough). You can create a subclass of NSLayoutManager to handle additional text attributes, whether inherent or not.
NSLayoutManager provides the threshold for text antialiasing. It looks at the AppleAntiAliasingThreshold default value. If the font size is smaller than or equal to this threshold size, the text is rendered aliased by NSLayoutManager. You can change the threshold value from the Appearance pane of System Preferences.
Thread Safety of NSLayoutManager
Generally speaking, a given layout manager (and associated objects) should not be used in more than one block, operation, or thread at a time. Most layout managers are used on the main thread, since it is the main thread on which their text views are displayed, and since background layout occurs on the main thread. If it is intended that a layout manager should be used on a background thread, first make sure that text views associated with that layout manager (if any) are not displayed while the layout manager is being used on the background thread, and, second, turn off background layout for that layout manager while it is being used on the background thread.
Noncontiguous layout is an optional layout manager behavior new in Mac OS X v10.5. Previously, both glyph generation and layout were always performed, in order, from the beginning to the end of the document. When noncontiguous layout is turned on, however, the layout manager gains the option of performing glyph generation or layout for one portion of the document without having done so for previous sections. This can provide significant performance improvements for large documents.
Noncontiguous layout is not turned on automatically because direct clients of NSLayoutManager typically have relied on the previous behavior—for example, by forcing layout for a given glyph range, and then assuming that previous glyphs would therefore be laid out. Clients who use NSLayoutManager only indirectly—for example, those who use NSTextView without directly calling the underlying layout manager—can usually turn on noncontiguous layout without difficulty. Clients using NSLayoutManager directly need to examine their usage before turning on noncontiguous layout.
To turn on noncontiguous layout, use AllowsNonContiguousLayout. In addition, see the other methods in "Managing Noncontiguous Layout," many of which enable you to ensure that glyph generation and layout are performed for specified portions of the text. The behavior of a number of other layout manager methods is affected by the state of noncontiguous layout, as noted in the discussion sections of those method descriptions.
So far the plugin implements a small subset of the functions in NSLayoutManager. If you miss a function, please email us and we can check whether we can add it for you.
- 15 properties
- property allowsNonContiguousLayout as boolean
- property attributedString as NSAttributedStringMBS
- property backgroundLayoutEnabled as boolean
- property font as NSFontMBS
- property Handle as Integer
- property hasNonContiguousLayout as boolean
- property hyphenationFactor as Double
- property showInvisibleCharacters as boolean
- property showsControlCharacters as boolean
- property showsInvisibleCharacters as boolean
- property textColor as NSColorMBS
- property textStorage as NSTextStorageMBS
- property usesFontLeading as Boolean
- property usesScreenFonts as boolean
- property InvisibleCharMapping(character as Integer) as string
- 21 methods
- method addTextContainer(container as NSTextContainerMBS)
- method characterIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS, byref partialFraction as Double) as Integer
- method Constructor
- method glyphIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS) as Integer
- method glyphIndexForPoint(point as NSPointMBS, container as NSTextContainerMBS, byref partialFraction as Double) as Integer
- method glyphRangeForTextContainer(container as NSTextContainerMBS) as NSRangeMBS
- method lineFragmentRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS) as NSRectMBS
- method lineFragmentRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS, withoutAdditionalLayout as boolean) as NSRectMBS
- method lineFragmentUsedRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS) as NSRectMBS
- method lineFragmentUsedRectForGlyphAtIndex(glyphIndex as Integer, byref effectiveRange as NSRangeMBS, withoutAdditionalLayout as boolean) as NSRectMBS
- method locationForGlyphAtIndex(glyphIndex as Integer) as NSPointMBS
- method rangeOfNominallySpacedGlyphsContainingIndex(glyphIndex as Integer) as NSRangeMBS
- method rectArrayForCharacterRange(charRange as NSRangeMBS, selCharRange as NSRangeMBS, container as NSTextContainerMBS, byref rectCount as Integer) as NSRectMBS()
- method rectArrayForGlyphRange(glyphRange as NSRangeMBS, selGlyphRange as NSRangeMBS, container as NSTextContainerMBS, byref rectCount as Integer) as NSRectMBS()
- method removeTextContainerAtIndex(index as Integer)
- method replaceGlyphAtIndex(glyphIndex as Integer, newGlyph as Integer)
- method replaceTextStorage(newTextStorage as NSTextStorageMBS)
- method setCharacterIndex(charIndex as Integer, glyphIndex as Integer)
- method setExtraLineFragmentRect(fragmentRect as NSRectMBS, usedRect as NSRectMBS, TextContainer as NSTextContainerMBS)
- method setLineFragmentRect(fragmentRect as NSRectMBS, glyphRange as NSRangeMBS, usedRect as NSRectMBS)
- method usedRectForTextContainer(container as NSTextContainerMBS) as NSRectMBS
This class has no sub classes.
Some methods using this class:
- NSTextContainerMBS.replaceLayoutManager(l as NSLayoutManagerMBS)
- NSTextStorageMBS.addLayoutManager(l as NSLayoutManagerMBS)
- NSTextStorageMBS.removeLayoutManager(l as NSLayoutManagerMBS)
Some properties using for this class:
- NSTextViewMBS.layoutManager as NSLayoutManagerMBS
- NSTextContainerMBS.layoutManager as NSLayoutManagerMBS
Some examples which use this class:
The items on this page are in the following plugins: MBS MacCocoa Plugin.
MBS FileMaker tutorial videos