GetInfo for Font Size

Posted by Candido on Tue 05 Jan 2010 11:28 PM — 7 posts, 32,843 views.

USA #0
Is there a GetInfo for the current output font size? I've looked at the list and I see the GetInfo's for width and height, but I'm referring to the size that you choose in the output settings.

In other words, I want to do this:

WindowFont("window", "standard", GetInfo(20), (font size function would go here), false, false, false, false, 1, 0)

Which would give the miniwindow the same font as the output window. If not, an alternative method would also be good if anyone knows one.
USA #1
I asked a similar question recently, and the equation Nick gave should work well for you, I think.
Template:post=9878
Please see the forum thread: http://gammon.com.au/forum/?id=9878.


Basically, you'd probably want to do this:

function output_font_size()
  return math.floor((0.5 + GetInfo(212)) * 72 / GetDeviceCaps(90))
end


EDIT: Oddly, this returns 12 for me, when my output font is Dina 10pt. Maybe I messed something up in translation.

EDIT 2: And if I change my font to 9pt or 8pt Dina, the value returned is 11 or 10. Yet if I change to, say, 10pt Dotum (next down on my font list), it returns 10 as expected. I think we must be missing a factor in the formula.

EDIT 3: Alternatively, could we maybe just have additional GetInfo() and WindowFontInfo() selectors for the font's size? *laughs*
Amended on Tue 05 Jan 2010 11:46 PM by Twisol
Netherlands #2
Why be so difficult?

Note("My output font is "..GetOption("output_font_height").."pt tall.")


Should do wonders.
USA #3
Well.... That's handy.
Netherlands #4
You can get basically every persistent world-specific setting through GetOption() and GetAlphaOption(). So basically everything in world configuration, but also some settings Nick implemented that don't have interface settings to toggle them (which you'd do with the Set* varieties).

Just open a world file in notepad, and look through it for the specific string you need. Sometimes they're a bit awkwardly named or hard to find, and yet in other times they're missing alltogether - in which case you need to temporarily change the option and save your world file so you can see it after all as MUSHclient only saves non-default settings by default.
Australia Forum Administrator #5
Twisol said:


EDIT: Oddly, this returns 12 for me, when my output font is Dina 10pt. Maybe I messed something up in translation.



I think your problem is here, from the page you quoted:

Nick Gammon said:

According to the Microsoft knowledge base article, the character height, which is what we want, is the font height minus the internal leading. So we need to take WindowFontInfo (win, "f", 1) and subtract WindowFontInfo (win, "f", 4) .


You have used the font height (effectively selector 1) without subtracting the leading (selector 4). Thus this method won't work for the world fonts, however as Worstje says, you don't need to bother anyway.
USA #6
Perfect, thanks.