Re: conflict between Core Graphics and NSView graphics
Re: conflict between Core Graphics and NSView graphics
- Subject: Re: conflict between Core Graphics and NSView graphics
- From: Aki Inoue <email@hidden>
- Date: Mon, 26 Apr 2010 12:50:38 -0700
OK, sounds like you're being affected by the text matrix.
In CG, there are 3 font properties that determine the font rendering: font name, font size, and text matrix.
You need to manage all 3.
The easiest approach is to use -[NSFont setInContext:] to let the Cocoa object set all 3 properties for you.
Another approach is to reset the text matrix directly using CGContextSetTextMatrix.
Note that the translation part (tx and ty components) are directly tied to the text position (CGContextSetTextPosition).
You need to reset the text matrix before calling CGContextSetTextPosition, or you could just update the text position using CGContextSetTextMatrix.
Aki
On Apr 26, 2010, at 12:39 PM, Bill Appleton wrote:
> hi Aki,
>
> i am using CGContextShowGlyphsWithAdvances
>
> i have a very large amount of core graphics code, i thought it was compatible with cocoa
>
> i see the text in the right spot but the size is gigantic
>
>
>
> thanks,
>
> bill
>
>
>
>
>
> On Mon, Apr 26, 2010 at 12:34 PM, Aki Inoue <email@hidden> wrote:
> Bill,
>
> How are you rendering the text ?
>
> We recommend sticking to Cocoa text rendering API in order to support proper Unicode rendering.
>
> Thanks,
>
> Aki
>
> On Apr 26, 2010, at 12:24 PM, Bill Appleton wrote:
>
> > hi all
> >
> > i converted a bunch of quickdraw code to core graphics successfully -- it
> > worked
> >
> > now i am converting a bunch of carbon UI code to cocoa
> >
> > but when I draw text, my fonts are wrong and my font sizes are much too big
> >
> > i am getting the CGContextRef from the NSWindow in the drawRect handler, and
> > then setting the CG font and size, etc. like before
> >
> > but it is as if I need to also set the NSFont or something like that
> >
> > other graphics (lines, bitmaps, etc.) are drawing correctly
> >
> > can someone shed some light on this and/or point me to some documentation?
> >
> >
> > thanks,
> >
> > bill appleton
> > _______________________________________________
> >
> > 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