• 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: 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


  • Follow-Ups:
    • Re: What's wrong with this font thing?
      • From: Randall Meadows <email@hidden>
    • Re: What's wrong with this font thing?
      • From: Buddy Kurz <email@hidden>
References: 
 >What's wrong with this font thing? (From: Randall Meadows <email@hidden>)

  • Prev by Date: Re: What's wrong with this font thing?
  • Next by Date: Re: Is there an equivalent to std::min/std::max for Cocoa programmer's
  • 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