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
1
vote
0 answers

How can I tell the text alignment on a UITextView when the default is set to UITextAlignmentNatural

I have a UITextView that has the property UITextAlignmentNatural but I want to know if the text is aligned left-to-right or right-to-left. How can I tell if it's LTR or RTL For more context, I'm trying to do this within my NSLayoutManager subclass…
MichaelGofron
  • 1,310
  • 4
  • 15
  • 29
1
vote
2 answers

Does NSAttributedString's enumerateAttribute method's block pass character ranges or glyph ranges?

tl;dr: if I call NSAttributedString's enumerateAttribute:inRange:options:usingBlock: method, does the range argument to the block pass a glyph range or a character range? I have a text view in my app that needs to behave like Notes.app in that when…
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
1
vote
1 answer

Strange changes to NSLayoutManager in 10.11 and higher

My goal is to make text selection behaviour similar to Apple Pages, MS Word and any other text processor, when NSTextView selects ONLY text glyphs and not any indents or the whole NSTextContainer size like by default NSTextView's behavior. With that…
Vitalii Vashchenko
  • 1,777
  • 1
  • 13
  • 23
1
vote
1 answer

Redrawing a single rect for a line fragment in NSTextView

We have an NSTextView that needs to have single line fragments redrawn on certain events. Essentially, it is an outline. So when a particular line gets the message "tab out", we want to move the rect containing the glyphs rather than just inserting…
Dexter
  • 5,666
  • 6
  • 33
  • 45
1
vote
1 answer

Cocoa: NSTextStorageDelegate has out-of-date NSLayoutManager?

I'm working with a NSTextView and have a delegate set for its -textStorage property. Upon receipt of -textStorageDidProcessEditing: I need to apply attributes to portions of the text. My attributes are being applied, but they are always applied to…
d11wtq
  • 34,788
  • 19
  • 120
  • 195
1
vote
1 answer

How to select all text that you can see in the NSTextView?

I would like a way to programmatically select just the text in the bounds and have that change as the window scrolls or changes bounds. SelectAll will not work. I don't want the whole document. My goal is to react to whatever text scrolls into view…
johnrubythecat
  • 1,003
  • 1
  • 13
  • 31
1
vote
1 answer

drawGlyphsForGlyphRange in Swift (Displaying Invisible characters). replaceGlyphAtIndex deprecated

I am trying to show Invisible characters using below class & func, and it is working fine. But replaceGlyphAtIndex is deprecated in OS X 10.11 and we need to use setGlyhs() setGlyphs(<#T##glyphs: UnsafePointer##UnsafePointer#>,…
Shiva Kumar
  • 389
  • 3
  • 22
1
vote
1 answer

NSLayoutManager/NSTextContainer Ignores Scale Factor

I am attempting to measure an NSAttributedString's height given a constant width using the following method: -(CGFloat)calculateHeightForAttributedString:(NSAttributedString*)attributedNotes { CGFloat scrollerWidth = [NSScroller…
Deadpikle
  • 356
  • 6
  • 22
1
vote
1 answer

How to count the number of glyphs in NSLayoutManager

How do I get the total number of glyphs that are in NSLayoutManager? I was making a cursor layer to overlay on a custom text view like this: func moveCursorToGlyphIndex(glyphIndex: Int) { // get bounding rect for glyph var rect =…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1
vote
0 answers

NSLayoutManager: Calling setLocation(_:forStartOfGlyphRange:) disables kerning in the whole string?

I created simple NSLayoutManager subclass that allows to set custom layout location for defined substrings: class PositionableLayoutManager: NSLayoutManager { var xOffsetsPerGlyphRange = [(NSRange, CGPoint)]() override func…
Rasto
  • 17,204
  • 47
  • 154
  • 245
1
vote
0 answers

Fitting NSlayoutManager into UIView

I have set up a UIView with NSLayoutManager (TextKit) and the UIView is placed in a UIScrollView. Im having trouble resizing the UIView to the size of the text so that It can be scrolled. Currently the text fills the screen but the scrollView…
1
vote
1 answer

How to render text in a CALayer using NSLayoutManager?

I am using the trio of NSLayoutManager, NSTextStorage & NSTextContainer to render text in a layer-backed NSView. I am under the impression that the view will be more performant if I can override wantsUpdateLayer to return true and thus be using…
Sam
  • 2,745
  • 3
  • 20
  • 42
1
vote
0 answers

How to clear the effects of NSLayoutManager.drawGlyphsForGlyphRange(...)?

I have a NSView elements that are being reused primarily to draw different text as they scrolls within an NSScrollView. I am using the trio of NSTextStorage, NSLayoutManager and NSTextContainer to display the text and the following is the call made…
Sam
  • 2,745
  • 3
  • 20
  • 42
1
vote
0 answers

Hide glyph on NSTextLayout

I have a UITextView with a custom NSTextLayout: VPLayoutManager.h #import @interface VPLayoutManager : NSLayoutManager @end VPLayoutManager.m #import "VPLayoutManager.h" @implementation…
genesisxyz
  • 778
  • 3
  • 14
  • 29
1
vote
0 answers

How to change the font size of NSAttributedString in ios7

I have loaded a NSAttributedstring to an UITextview. The string contains texts with different font sizes. I want to change the size of text using UISlider. So i am trying to increase the font size accordingly. I can set a specific font size for the…
Karan Alangat
  • 2,154
  • 4
  • 25
  • 56