• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What's wrong with this font thing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's wrong with this font thing?


  • Subject: Re: What's wrong with this font thing?
  • From: Graham Cox <email@hidden>
  • Date: Thu, 30 Oct 2008 10:53:51 +1100


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 (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


References: 
 >What's wrong with this font thing? (From: Randall Meadows <email@hidden>)
 >Re: What's wrong with this font thing? (From: Peter Ammon <email@hidden>)
 >Re: What's wrong with this font thing? (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: Problem with NSData to NSString to NSData
  • Next by Date: Re: What's wrong with this font thing?
  • Previous by thread: Re: What's wrong with this font thing?
  • Next by thread: Re: What's wrong with this font thing?
  • Index(es):
    • Date
    • Thread