If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Find font (size problem)

You can make good estimates based on averages. But if you really need precision and the maximum size the font can be to not exceed the limit, then the solution given by victor is the only solution.

Besides... define 'time critical' ? maybe this solution is fast enough. If you're not actually doing drawing, then this is quite fast. Entire wordprocessors and browser renderers rely on that very feature. Whatever you are trying to precalculate, the built in functions will probably do better/faster.

If you really can't afford a performance hit, consider using a monotype font like courier/consolas. Calculating the width of a tekst is then the width of a single char multiplied by the number of chars.

Re: Find font (size problem)

I think you misunderstood me.
Yes, you are actually drawing, but usually once once for a given case.

the testing phase where you "try" different sized fonts, you don't actually draw anything, you're only asking the API's to calculate how much width/height it would take if you did actually draw.

So this is only a calculation of size, not actually manipulating pixels. THe calculations are typically very fast. Actual drawing can be an order of magnitude slower, especially when you're goign to screen and want antialiassed or cleartype text. But like I said, you typically only actually draw once.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.