Re: Determining bounds of a glyph
Re: Determining bounds of a glyph
- Subject: Re: Determining bounds of a glyph
- From: Philip White <email@hidden>
- Date: Wed, 10 Mar 2010 14:47:44 -0600
On Mar 10, 2010, at 12:42 PM, David wrote:
> Phillip -- Have you made any progress on this? I am trying to draw glyphs onto an NSBitmapImageRep using drawGlyphsForGlyphRange:atPoint: and having similar problems. In my case the symptoms are that underline and strikethrough are not being drawn correctly.
>
> Right now, my guess is that some component of the text system is confused about where the baseline should be. That's the angle I am pursuing right now.
>
> David
Hi David,
I gave up using the drawGlyphsForGlyphRange: method as I just couldn't figure why it was drawing the glyphs were it was. I'm getting decent results now using NSBezierPath's appendBezierPathWithGlyph:inFont:. I set up the text system as though I were going to use NSLayoutManager to draw it. I use boundingRectForGlyphRange: to help size my font to fit the image width I want and then use glyphAtIndex: to get the glyph I want to draw.
If you decide to go this route you could add the underline and strikethrough manually to the bezier path without much difficulty.
I use the ascender and descender font metrics to determine where to start drawing the bezier path relative to image origin. You could also use these metrics to determine where to draw your marks.
-Philip
_______________________________________________
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