Fwd: Positioning of text
Fwd: Positioning of text
- Subject: Fwd: Positioning of text
- From: Jakob Egger <email@hidden>
- Date: Wed, 16 Dec 2015 21:50:59 +0100
> On 16 Dec 2015, at 19:02, eric g <email@hidden <mailto:email@hidden>> wrote:
>
> I was expecting the emoji to be drawn in the lower left corner and do not
> understand why is the character drawn so high. Why is the emoji drawn
> where it is drawn?
The horizontal padding is caused by the text containers lineFragmentPadding.
Concerning the vertical offset, you can find the following in the docs of -drawGlyphsForGlyphRange:atPoint:
"This method expects the coordinate system of the view to be flipped."
I'm not sure how to make your context flipped, the following works but is deprecated:
NSGraphicsContext.setCurrentContext(NSGraphicsContext(CGContext: binContext.CGContext, flipped: true))
But then you also need to change the current transformation matrix to make the end result upright:
let t = NSAffineTransform()
t.translateXBy(0, yBy: kSquareSize)
t.scaleXBy(1, yBy: -1)
t.concat()
I assume that probably it would be easier to use Core Text for drawing to a Bitmap Context.
Jakob
_______________________________________________
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