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: Buddy Kurz <email@hidden>
- Date: Wed, 29 Oct 2008 16:29:49 -0700
- Divide the space available by the measured width to find the scale
factor
You can also use the scale factor to create a new font with a
fractional size.
I have the same problem for a terminal emulator - I need the largest
fixed font that will fit in a particular character spacing. When I
resize the window the sizes jump all over the place and the font is
clearly changing in subtle ways.
On Oct 29, 2008, at 4:15 PM, Peter Ammon wrote:
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
_______________________________________________
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