Re: What's wrong with this font thing?
Re: What's wrong with this font thing?
- Subject: Re: What's wrong with this font thing?
- From: Peter Ammon <email@hidden>
- Date: Wed, 29 Oct 2008 16:15:47 -0700
On Oct 29, 2008, at 3:45 PM, Randall Meadows wrote:
OK, I have to assume that I'm doing something really wrong here, but
man, I sure can't see it. Maybe my understanding is out of whack,
maybe some kind soul will show me the light... (Sorry for the
length, I'm trying to include all relevant information up front.)
I am attempting to replicate an API call that is available on
another platform, but not on Mac OS X. The call in question takes a
string, a font, a width, and reduces the font size (if necessary)
theoretically applied to that string such that when drawn, that
string would occupy no more than the specified width (down to a
mimimum font size also specified), and then returns the adjusted
font size as well as the NSSize that the string would occupy if it
were to be drawn with that font at that adjusted size.
Trying to find the right font size to just fit the text seems a bit
archaic. Here is a different approach:
- Measure the string with some font
- Divide the space available by the measured width to find the scale
factor
- Use CGContextScaleCTM() to apply the scale to the current transform
- Draw the string with that font. It will scale nicely and fit into
the available space.
-Peter
_______________________________________________
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