From: Scott T. <ea...@ma...> - 2009-07-02 11:39:05
|
On Jul 2, 2009, at 2:37 AM, Duncan McGregor wrote: > On Wed, Jul 1, 2009 at 11:20 PM, Scott Thompson<ea...@ma...> wrote: > >> If I understand... you're going all the way to NSGraphicsContext >> just to flip the coordinate system? That's a long row to hoe :-). > > It would be, but I'm actually going to NSGraphicsContext so that I can > draw NSImages and NSStrings on the PDF without having to bang my head > against Quartz, especially in its font handling. :-) I know what you mean, Quartz 2D doesn't have any "font handling". I usually recommend a higher-level library like Cocoa for the text, but then I (personally) usually use the CG level calls instead of NSBezierPath, NSImage and friends. OK, the code I gave you should still work out OK with the exception of the images. As I recall, NSImage is "smart" in that it respects the flipped bit of the context to do what it thinks is the Right Thing™ (although all of NSImage's "smarts" tend to bite me in the behind often... I've heard it's much better under Snow Leopard). You might be able to set the flipped bit on the NSImages without running into a RubyCocoa crash. Failing that, you can always, use some transform magic to flip the coordinate system the right way around right before you draw an image and then quickly put it back. Scott |