Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, I'd go for a NStextView instead, where the associated NSLayoutManager and NSTextStorage components are already set for you. Then, you can achieve what you are trying to do by doing the following steps:</p> <ul> <li><p>Subclass NSATSTypesetter to draw custom glyphs for any characters you want by overriding :</p> <p><pre>- (void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin<code></p> <p>- (NSRect)boundingBoxForControlGlyphAtIndex:(NSUInteger)glyphIndex forTextContainer:(NSTextContainer *)textContainer proposedLineFragment:(NSRect)proposedRect glyphPosition:(NSPoint)glyphPosition characterIndex:(NSUInteger)charIndex </p></li> <li><p>Subclass NSLayoutManager and set its type setter with the above one. Then override:</p></li> </ul> <p>-(void)drawGlyphsForGlyphRange:(NSRange)glyphsToShow atPoint:(NSPoint)origin { [self.typesetter drawGlyphsForGlyphRange:glyphsToShow atPoint:origin];</p> [super drawGlyphsForGlyphRange:glyphsToShow atPoint:origin]; </code></pre> <p>} </p> <ul> <li><p>Replace the layout manager of the NSTextView with the above one:</p> <p>[[textView textContainer] replaceLayoutManager:[[[MyLayoutManager alloc] init] autorelease]];</p></li> </ul> <p>Basically, you have to check NSLayoutManager and NSATSTypesetter classes for anything related to text custom drawing. Also there is a detailed guide about all this <a href="https://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TextLayout/TextLayout.html" rel="nofollow">here</a>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload