• 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
Fastest way to predict bounding box for a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fastest way to predict bounding box for a string


  • Subject: Fastest way to predict bounding box for a string
  • From: Ivan Kourtev <email@hidden>
  • Date: Mon, 6 Feb 2006 18:56:43 -0500

Hello,

I have an application where I need to draw a single-word attributed string as big as possible but not exceeding a specific fitting rectangle. I did this in principle by starting with a certain font size, getting the string bounding box, then increasing or decreasing the font size (while changing the string font attribute) until the bounding box is the largest fitting in the rectangle. I am assuming this method can be computationally expensive -- as a matter of fact I can 'see' a nearly one second delay (on a G5 DC 2GHz) when the rectangle to fit in is around 1,000x1,000.

Any ideas on how to get this size quicker? Is there any way that has escaped my attention that can return the biggest font size such that the particular string does not exceed a given bounding rectangle? Or should I just fall back to binary search of a certain interval of font sizes? Maybe caching the the size of a representative character in every size and getting a very good first guess for the required font size (particularly if the font is fixed width)? Any ideas or suggestions?

Thanks for any help.

--
ivan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Fastest way to predict bounding box for a string
      • From: Greg Herlihy <email@hidden>
    • Re: Fastest way to predict bounding box for a string
      • From: Charlton Wilbur <email@hidden>
    • Re: Fastest way to predict bounding box for a string
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: NSTextView line indentation
  • Next by Date: Re: Fastest way to predict bounding box for a string
  • Previous by thread: NSTextView line indentation
  • Next by thread: Re: Fastest way to predict bounding box for a string
  • Index(es):
    • Date
    • Thread