Jump to content

font size in pixels?


HighGuy
 Share

Recommended Posts

Is it possible to calculate the font height/width in pixels from the values used in GUISetFont()?

F.ex. I want to know the pixel size of a string to set the height and width of the control (Label, Button, ...) accordingly. I worry that it is not possible because every font might behave different .

Link to comment
Share on other sites

Is it possible to calculate the font height/width in pixels... <snip>

<{POST_SNAPBACK}>

Funny you should ask, I was just researching this yesterday. Theoretically, since a point is 1/72 of an inch, the font size in pixels can be calculated as:

pixels = points ( screen dpi / 72 )

But even if we skip over the whole nightmare about which actual "inch" variant you base it on (apparently they originally used the French inch, which isn't quite the same as an English inch) it's kind of a fuzzy determination of a font's actual size, as far as I can tell. Some fonts include leading (white space above and below lines) in the point size and some don't, so fonts can be the same size in points but actually not the same height, while line height can be anywhere from the actual point size to the point size plus some variable amount of leading.

And then there's width... for monospace fonts, where each letter and space is exactly the same size, the calculation above works fine. But for proportional fonts, where the letter "w" is five times (I'm totally guessing at the number) as wide as the letter "i" it's not really something you can calculate because it depends what letters are in the text being displayed.

So although I'm happy I could actually give you a formula, I don't think it's really going to help you a whole lot... Sorry! :lmao:

LadyLong

.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein
Link to comment
Share on other sites

In the font I'm viewing your post in, the "w" is 9 times the width of the "i"

<{POST_SNAPBACK}>

Yeah, after I posted it I realized it looked like a lot more than 5x. But I didn't actually stop and measure it. I think that means you're more of a geek than me, yes? :lmao:
.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein
Link to comment
Share on other sites

Yeah, after I posted it I realized it looked like a lot more than 5x. But I didn't actually stop and measure it. I think that means you're more of a geek than me, yes?  o:)

<{POST_SNAPBACK}>

Oh definitely. I actually went to the trouble of loading up the Au3 Info Tool and using the magnify feature just to make sure I was counting right. :lmao:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...