rectArrayForCharacterRange and lineSpacing (was: text highlighting with CALayer and NSTextView)

2012-09-03 Thread Koen van der Drift

On Aug 25, 2012, at 6:10 AM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 NSRectArrayrectArray = [[self layoutManager] 
 rectArrayForCharacterRange: aRange

 withinSelectedCharacterRange: selectedRange
 
 inTextContainer: [self textContainer]
   
 rectCount: rectCount];


For some reason, the height of the last rect in the NSRectArray is smaller than 
the other ones, and therefore the CALayer I draw behind the corresponding range 
of text looks wrong.

My font size is 16, and the line spacing is set to 12.   For most rects, the 
height returned is 31 (= 16 + 12 + 3), but for the last one, the height is 19 ( 
= 16 + 3).

So it seems for the last rect, the linespace is ignored.  I can test for that, 
and correct it, but I was wondering what is going on.  And where does the '3' 
come from?

- Koen.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: rectArrayForCharacterRange and lineSpacing (was: text highlighting with CALayer and NSTextView)

2012-09-03 Thread Graham Cox

On 04/09/2012, at 4:02 AM, Koen van der Drift koenvanderdr...@gmail.com wrote:

 For some reason, the height of the last rect in the NSRectArray is smaller 
 than the other ones, and therefore the CALayer I draw behind the 
 corresponding range of text looks wrong.
 
 My font size is 16, and the line spacing is set to 12.   For most rects, the 
 height returned is 31 (= 16 + 12 + 3), but for the last one, the height is 19 
 ( = 16 + 3).
 
 So it seems for the last rect, the linespace is ignored.  I can test for 
 that, and correct it, but I was wondering what is going on.  And where does 
 the '3' come from?


I think that's correct.

For the last line, there's no further line to space and so the bottom of the 
rectangle is at the bottom of the text. Or another way to think about it is 
that the line spacing is inserted above each line.

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: rectArrayForCharacterRange and lineSpacing (was: text highlighting with CALayer and NSTextView)

2012-09-03 Thread Kyle Sluder
On Sep 3, 2012, at 11:02 AM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 
 So it seems for the last rect, the linespace is ignored.  I can test for 
 that, and correct it, but I was wondering what is going on.  And where does 
 the '3' come from?

There was a WWDC 2012 session on Core Text that Ned Holbrook gave that did a 
decent job explaining the different components that make up a line's 
typographic bounds.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: rectArrayForCharacterRange and lineSpacing (was: text highlighting with CALayer and NSTextView)

2012-09-03 Thread Koen van der Drift
Thanks, I'll have a look at that.

- Koen.

On Sep 3, 2012, at 19:01, Kyle Sluder k...@ksluder.com wrote:

 On Sep 3, 2012, at 11:02 AM, Koen van der Drift koenvanderdr...@gmail.com 
 wrote:
 
 
 So it seems for the last rect, the linespace is ignored.  I can test for 
 that, and correct it, but I was wondering what is going on.  And where does 
 the '3' come from?
 
 There was a WWDC 2012 session on Core Text that Ned Holbrook gave that did a 
 decent job explaining the different components that make up a line's 
 typographic bounds.
 
 --Kyle Sluder

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com