Post

Replies

Boosts

Views

Activity

NSLayoutManager.drawGlyphs() can not display MarkDown attributed string
We use NSLayoutManager/NSTextStorage/NSTextContainer to display markdown attributed string on a canvas. MarkDown string was processed properly, but NSLayoutManager just exhibits the plain text. The code is as follows:     var layoutmanager = NSLayoutManager()     var textstorage = NSTextStorage()     var textcontainer = NSTextContainer()   var attrStr = try AttributedString.init(markdown: "**test**", options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace)) var attrString = NSMutableAttributedString(attrStr)  self.textstorage.setAttributedString(attrString!) // draw text layout     let range = self.layoutmanager.glyphRange(for: self.textcontainer)     self.layoutmanager.drawBackground(forGlyphRange: range, at: self.textLocation)     self.layoutmanager.drawGlyphs(forGlyphRange: range, at: self.textLocation) Is it because TextKit 1 does not support markdown string display or I miss something else ? Any help will be appreciated. Thanks!
1
0
1.4k
Sep ’21