HighGuy Posted January 28, 2005 Share Posted January 28, 2005 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 More sharing options...
LadyLong Posted January 28, 2005 Share Posted January 28, 2005 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! 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 More sharing options...
therks Posted January 28, 2005 Share Posted January 28, 2005 But for proportional fonts, where the letter "w" is five times (I'm totally guessing at the number) as wide as the letter "i"In the font I'm viewing your post in, the "w" is 9 times the width of the "i"Not trying to correct, I just thought it was interesting. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
LadyLong Posted January 30, 2005 Share Posted January 30, 2005 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? .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 More sharing options...
CyberSlug Posted January 30, 2005 Share Posted January 30, 2005 It appears that the Win32 API has functions for this purpose; however, the data structures required are not supported by AutoIt's DllCall.... Perhaps this could be a post for the "Idea Lab" Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
therks Posted January 30, 2005 Share Posted January 30, 2005 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? <{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. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
jpm Posted January 30, 2005 Share Posted January 30, 2005 Not a solution to your problem but now fontsize 8.5 works in 3.1.0.3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now