Re: Align attributed string to baseline
Re: Align attributed string to baseline
- Subject: Re: Align attributed string to baseline
- From: "email@hidden" <email@hidden>
- Date: Fri, 07 Dec 2012 22:15:08 +0000
On 7 Dec 2012, at 17:40, Leonardo <email@hidden> wrote:
> Hi,
> I am getting serious difficulties at drawing an attributed string within an
> attachmentCell and get it aligned on the baseline.
> I have a NSTextView. I add an attachment with its attachmentCell.
> In the method cellFrameForTextContainer I return a
> cell.frame.height = font.ascender - font.descender;
> In the method drawWithFrame: of the cell, I draw the string with
> drawAtPoint: cellFrame.origin.x, cellFrame.origin.y - font.descender;
> It works well with some font and size: the attachment string is aligned with
> the rest of the text (with same font and size) in the NSTextView.
> E.g. with Futura Medium >= 17 the string is "always" aligned.
>
> But with Futura Medium < 18 the string goes lower than the baseline. Why?
> What do I miss there?
Try using the following method instead:
-drawWithRect:options:attributes:
See Aki Inoue's explanation in http://lists.apple.com/archives/cocoa-dev/2012/Sep/msg00442.html
-drawAtPoint uses a different layout strategy that can have these sort of effects.
Jonathan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden