Questions tagged [nslayoutmanager]

Glyph layout engine in iOS and OSX

Responsible for converting characters drawn from NSTextStorage and laying them out as glyphs following the display/geometric constraints provided by one or more NSTextContainer.

120 questions
2
votes
0 answers

iOS7 glyphRangeForTextContainer - select all glyphs / all text range in a UITextView

I am trying to achieve linespacing when typing into a UITextView. I have this function which seems to render the linespacing only for all the characters upto the cursor position when you click inside the UITextView. How do I write the function to…
Wael
  • 489
  • 6
  • 19
2
votes
0 answers

NSTextView lag during typing

I have two NSTextViews with a shared custom NSTextStorage subclass. The textviews mirror each other contents. This works fine until I press enter. Then the second textview starts lagging or doesn't even show any new input. This happens regardless of…
user965972
  • 2,489
  • 2
  • 23
  • 39
2
votes
1 answer

Bounding Rectangle using Core Text

Please correct me if I'm wrong. I tried to work out the exact bounding rectangle of a character using Core Text. But the height I received was always bigger than the actual height of the drawn character on the screen. In this case, the actual height…
L N
  • 2,856
  • 4
  • 20
  • 30
2
votes
1 answer

Animate NSLayoutManager drawing

I have an NSLayoutManager which is drawing text using the following code: [[self textLayoutManager] drawGlyphsForGlyphRange: NSMakeRange(0, [[self text] length]) atPoint: textFrame.origin]; in my view's…
Patrick Perini
  • 22,555
  • 12
  • 59
  • 88
2
votes
1 answer

Laying out text in NSTextView around a subview

What I’m trying to do is have an NSTextView and add custom NSView subviews to it, but have it so the text can layout around the subviews. Right now, I can easily add a subview to the textview but of course, that goes into the textview and the text…
jbrennan
  • 11,943
  • 14
  • 73
  • 115
1
vote
0 answers

NSLayoutManager for Line Numbering in UITextVIew

I am attempting to create an iOS LineNumberLayoutManger in Swift to be used in a TextKit 2 UITextView. My problem is the line number variable is being overwritten when I enter a new line with the return key. The revised code sample below can be…
user46938
  • 59
  • 4
1
vote
1 answer

Drawing outside content insets with drawGlyphsForGlyphRange

I'm trying to show some extra symbols next to lines in NSTextView, based on text attributes. I have successfully subclassed NSLayoutManager, but it seems that layout manager can't draw outside the area set by textContainerInset. Because my text view…
Tritonal
  • 607
  • 4
  • 16
1
vote
1 answer

How to remove default image icon in NSTextAttachment?

I have an NSAttributedString that can contain NSTextAttachments. I have subclassed the NSTextAttachment and have a property that stores an error message if there was a problem downloading the attachment's image. I am also subclassing NSLayoutManager…
1
vote
0 answers

NSLayoutManager provides wrong lineFragmentUsedRect on first load

So I'm trying to get the lineFragment size for each line in a UITextView's NSLayoutManager. On the first load, it provides values which are larger than the textView layouts. I have a textview which fills the ViewControllers view with Autolayout. A…
Jan
  • 1,827
  • 2
  • 16
  • 29
1
vote
1 answer

insert GlyphProperty.null in shouldGenerateGlyphs causes cursor misplacement problem

I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the…
Chow Fred
  • 11
  • 1
1
vote
1 answer

NSLayoutManager drawGlyphs endless loop when UITextView isScrollingEnabled is false

I'm having a custom NSLayoutManager with these two methods overwritten: override func drawGlyphs(forGlyphRange glyphsToShow: NSRange, at origin: CGPoint) { super.drawGlyphs(forGlyphRange: glyphsToShow, at: origin) let characterRange =…
user1007522
  • 7,858
  • 17
  • 69
  • 113
1
vote
0 answers

NSLayoutManager returns incorrect character index when tapping on LTR text in RTL attributed text

I wrote code to detect if the user taps within a specific range in UILabel. It seems to be working in most cases, but I have noticed that tapping the last line of an attributed text creates inconsistent results. public static bool DidTapRange(this…
user246392
  • 2,661
  • 11
  • 54
  • 96
1
vote
1 answer

Accessing NSTextView metrics

I have an NSTextVIew in which I am only showing mono-spaced characters from the standard alphabet. So no numbers, special characters, emojis, etc. Each character equals one glyph. On top of the text I need to draw some shapes, and I am looking for a…
koen
  • 5,383
  • 7
  • 50
  • 89
1
vote
1 answer

NSLayoutManager returns incorrect glyphIndex for mousePosition in NSTextView

I have an NSTextView subclass as the right item in an NSSplitViewController, the left panel is an NSOutlineView. To process mouse clicks while the command key is pressed in the text view, I added the following to find the glyph that is under the…
koen
  • 5,383
  • 7
  • 50
  • 89
1
vote
0 answers

TextEdit/NSTextView: line height changes when typing after an inline image

I have a Mac app with an embedded rich-text NSTextView, but the same problem can be reproduced with TextEdit: When a line contains only an image and no text, typing right after the image causes the text below to move downwards. Open a new…
Mark
  • 6,647
  • 1
  • 45
  • 88