Re: Fastest way to predict bounding box for a string
Re: Fastest way to predict bounding box for a string
- Subject: Re: Fastest way to predict bounding box for a string
- From: email@hidden
- Date: Mon, 6 Feb 2006 16:11:26 -0800
You should be able to do better than binary search with linear
extrapolation.
Meaning, given size size of your string is "fontSize" at
"baseSize" (e.g. 12 or whatever is a suitable default):
nextTestSize = baseSize * (availableSize / fontSize)
Just looping with that might spin you for a while - you could try
that once and then start shrinking the text size until it fits.
That's good if you're happy to step down in integer sizes... if
you're going to be doing -= 0.0000000001 each time through your loop,
you're still stuck.
This will probably be more accurate for larger base sizes, as
antialiasing will have less of an effect, so a base size of 100 or
somesuch might be a better default than 12. It doesn't matter if
it's clearly too big - you'll likely only need to scale it once.
Wade
_______________________________________________
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