• 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: NSAttributedString location for drawing, glyph location and baseline
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAttributedString location for drawing, glyph location and baseline


  • Subject: Re: NSAttributedString location for drawing, glyph location and baseline
  • From: Alexander Reichstadt <email@hidden>
  • Date: Mon, 16 Jul 2012 00:02:21 +0200

I think I found it in, at least it looks correct:

CGFloat gb = [[NSTypesetter sharedSystemTypesetter] baselineOffsetInLayoutManager:[(NSTextView *)controlView layoutManager] glyphIndex:charIndex];

NSRect useFrame = cellFrame;
useFrame.origin.y += gb;

Thanks


Am 15.07.2012 um 23:40 schrieb Alexander Reichstadt:

> Hi,
>
> I have a subclass of NSAttachmentCell which draws itself into an NSTextView. Its y-location is wrong though when drawing the cell using
>
> - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *) controlView characterIndex:(NSUInteger)charIndex layoutManager: (NSLayoutManager *)layoutManager
>
> How do I determine the correct origin for cellFrame to ensure that the baseline of the text inside the NSTextView matches that of the text inside the cell to be drawn in the textview? In above call I use
>
> [self.displayWord drawInRect:cellFrame withAttributes:stringAttributes];
>
> to draw the string which in turn uses boundingRectWithSize to figure out the NSRect dimensions to accommodate the string?
>
> Thanks
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >NSAttributedString location for drawing, glyph location and baseline (From: Alexander Reichstadt <email@hidden>)

  • Prev by Date: NSAttributedString location for drawing, glyph location and baseline
  • Next by Date: +bundleForClass: category question
  • Previous by thread: NSAttributedString location for drawing, glyph location and baseline
  • Next by thread: +bundleForClass: category question
  • Index(es):
    • Date
    • Thread