• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Align attributed string to baseline
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Align attributed string to baseline (From: Leonardo <email@hidden>)

  • Prev by Date: Re: How to implement readonly property
  • Next by Date: Re: Remote control desktop from iPhone
  • Previous by thread: Align attributed string to baseline
  • Next by thread: Help Book icon — retina?
  • Index(es):
    • Date
    • Thread