Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Font Size Algorithm
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00965827
Message ID:
00965842
Views:
13
Hugo,

Look at the fontmetric() function.

For example:
? fontmetric( 1, "arial", 66 )
will tell you that 66 pt arial uses 99 vertical pixels.

It's a nonlinear function though look at this output:
for i = 10 to 17
   ? i, fontmetric( 1, "arial", i )
endfor
So I think you are stuck with iterating till you find the best fit.

>I was wondering if anyone knows of an equation that, given any width and height area, as well as a fontname, returns the appropiate size of a font to fill that area the best (I know it won't be perfect). Let's say I have a rectangle of 200w x 100h pixels, I want to fill it with the word 'Hello', I would need to set the fontsize to 66 if the font is Arial, so... how do I get that 66? Is there any equation I can use (I know I can do a loop thru all font sizes until I get the desired (best fit) size, but I want to use that iteration as a last workaround
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform