Re: boundingRectWithSize gives wrong size

2019-09-11 Thread Gabriel Zachmann via Cocoa-dev
> I must confess that I made the mistake of calculating the size of the text using the attributed string, but I did *not* assign the attributed string to the text layer, but instead I assigned the orig. plain string. That way, the text layer must have used a different font for rendering the

Re: boundingRectWithSize gives wrong size

2019-09-10 Thread Richard Charles via Cocoa-dev
> On Sep 10, 2019, at 10:54 AM, Gabriel Zachmann wrote: > >> I have had good results with CTLineGetTypographicBounds(). > > This seems to be suitable only for single lines of text. > But , usually, I've got 2 lines of text. > > I looked at Core Text a bit further, but I could not find how to

Re: boundingRectWithSize gives wrong size

2019-09-10 Thread Jens Alfke via Cocoa-dev
> On Sep 10, 2019, at 9:54 AM, Gabriel Zachmann wrote: > > The excess width is sometimes more, sometimes a bit less, I could not find a > pattern. > I guess , it has something to do with the actual glyphs in the string. How much bigger is it? By a fraction of a character width? Or is it more

Re: boundingRectWithSize gives wrong size

2019-09-10 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot to both of you for responding, and sorry for my delay! (In case you forget the context, I have enclosed my original question below.) >> NSRect string_rect = CGRectIntegral( [mesg_string boundingRectWithSize: >> drawRect_.size > What is drawRect_ set to when this is called? Here

Re: boundingRectWithSize gives wrong size

2019-08-28 Thread Jens Alfke via Cocoa-dev
> On Aug 28, 2019, at 12:33 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > NSRect string_rect = CGRectIntegral( [mesg_string boundingRectWithSize: > drawRect_.size What is drawRect_ set to when this is called? It's been a while since I used this, but IIRC the output width will be the

Re: boundingRectWithSize gives wrong size

2019-08-28 Thread Richard Charles via Cocoa-dev
> On Aug 28, 2019, at 1:33 PM, Gabriel Zachmann via Cocoa-dev > wrote: > > I am trying to determine the size of a piece of text using > boundingRectWithSize. > > The problem is that this method does not return the correct width. (The > height seems to be about right.) Sometimes, the width

boundingRectWithSize gives wrong size

2019-08-28 Thread Gabriel Zachmann via Cocoa-dev
I am trying to determine the size of a piece of text using boundingRectWithSize. The problem is that this method does not return the correct width. (The height seems to be about right.) Sometimes, the width is only a little bit too wide, sometimes it is much too wide. And I could not find a