On 30 Oct 2008, at 10:37 am, Randall Meadows wrote:

Doing that also shifts the rect that I'm trying to draw into. I'm doing multiple NSString drawInRect:withAttributes: calls, all within a single view.


Remember that transforms are always relative to the view's origin, so just scaling will move the rect. You have to transform to the origin, scale, then transform back to where you want to draw the text. If you were using NSAffineTransform it would go like this:

(warning: typed in Mail)

NSAffineTransform* transform = [NSAffineTransform transform];
[transform translateXBy:myRect.origin.x yBy:myRect.origin.y];
[transform scaleXBy:myScaleFactor yBy:myScaleFactor];
[transform translateXBy:-myRect.origin.x yBy:-myRect.origin.y];
[transform concat];

If using the CTM methods in Core Graphics, there are equivalent functions. This assumes that the rect's origin is where the text origin is, I can't remember if that's actually the case, but if it isn't then just translate to the necessary point and back.

You need to save/restore the graphics state around each drawing call.

(BTW Peter's approach is a good one, much easier than converting the glyphs to a path, but with identical results).

hth, Graham
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to