Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Miniwindows
➜ Default Font?
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Amun
(9 posts) Bio
|
Date
| Wed 10 Jul 2024 07:32 PM (UTC) |
Message
| Hi. I'm working on a project to capture instances of damage to gear and printing a list of damaged pieces, as well as how many times they've been damaged, at the top of my window.
I've got it all working, though there's one problem. When using "GetInfo(20)" it is selecting the chosen font (which, in this case, is "FixedSys") for the world, but it ignores the "Override with default" option, which is selected in my worlds.
I'd like to know how I detect whether the font is overridden with the default, and how do I determine what the default is? | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 10 Jul 2024 09:03 PM (UTC) Amended on Wed 10 Jul 2024 09:11 PM (UTC) by Nick Gammon
|
Message
| To find the default global font you can do this:
DefaultOutputFont = GetGlobalOption ("DefaultOutputFont")
However due to a bug in the code which I just noticed (it's been there for years!) in the current version of MUSHclient you need an extra space, like this:
DefaultOutputFont = GetGlobalOption ("DefaultOutputFont ")
I suggest trying both, and use the one which does not return nil, since the new version may take a while to be adopted.
Then to find if they have enabled it or not:
use_default_output_font = GetOption ("use_default_output_font")
That should return a 0 or 1 where 1 means enabled.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Amun
(9 posts) Bio
|
Date
| Reply #2 on Thu 11 Jul 2024 12:04 AM (UTC) Amended on Thu 11 Jul 2024 12:13 AM (UTC) by Amun
|
Message
| Thanks a bunch, Nick!
One last question, would there be an easy way to get the font height of the default font, such as GetInfo(212) does for the selected output font?
*edit*
I've found the answer to that question myself! GetGlobalOption( "DefaultOutputFontHeight" ) seems to do the trick.
One last question, finally! Where would I go to find the Font Size of the default output font? | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 11 Jul 2024 05:08 AM (UTC) |
Message
| You can see the global option names like this:
t = {}
-- Get global option names
for k, v in pairs (GetGlobalOptionList()) do
table.insert (t, v)
end
-- sort alphabetically
table.sort (t)
-- show the names and values of each option
for k, v in ipairs (t) do
print (v .. " = " .. GetGlobalOption (v))
end
In my case I see (amongst other things) this:
DefaultInputFont = Fixedsys
DefaultInputFontHeight = 9
DefaultInputFontItalic = 0
DefaultInputFontWeight = 400
DefaultLogFileDirectory = C:\Program Files (x86)\MUSHclient\logs\
DefaultMacrosFile =
DefaultOutputFont = Arial
DefaultOutputFontHeight = 6
So to answer your question:
DefaultOutputFontHeight = GetGlobalOption ("DefaultOutputFontHeight")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 11 Jul 2024 05:10 AM (UTC) Amended on Thu 11 Jul 2024 05:12 AM (UTC) by Nick Gammon
|
Message
|
Quote:
One last question, finally! Where would I go to find the Font Size of the default output font?
Wait a minute! You knew that! What is the difference between the DefaultOutputFontHeight and the font size? Aren't they the same?
Oh, you mean in pixels? You can find that out using the normal technique inside a miniwindow, the same as any other font.
http://gammon.com.au/mushclient/mw_text.htm#WindowFontInfo
See Hint 1 further down the page. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Amun
(9 posts) Bio
|
Date
| Reply #5 on Thu 11 Jul 2024 02:46 PM (UTC) |
Message
|
Nick Gammon said:
Wait a minute! You knew that! What is the difference between the DefaultOutputFontHeight and the font size? Aren't they the same?
I *didn't* know that! Thanks for all the help, Nick. I'm a big fan of your program and have been for many years. :) | Top |
|
Posted by
| Amun
(9 posts) Bio
|
Date
| Reply #6 on Thu 11 Jul 2024 07:49 PM (UTC) |
Message
| I'm having some trouble still!
I'm using the following bit of code, which accurately detects whether or not we're using the default output font option:
selectedFont = GetInfo(20)
selectedFontHeight = GetInfo(212)
if GetOption( "use_default_output_font" ) > 0 then
selectedFont = (GetGlobalOption( "DefaultOutputFont" ) or GetGlobalOption( "DefaultOutputFont " ))
selectedFontHeight = GetGlobalOption( "DefaultOutputFontHeight" )
end
However, GetGlobalOption( "DefaultOutputFontHeight" ) is returning "9", which is the font size, but it creates overlaps when I draw my text in rows using this value.
WindowFontInfo("Tepes_Repair", "Tepes_Repair_Texts_1", 1) returns 15 for me, after I've initialized the text, which is the value I think I want, as it prints cleanly for me with no overlap if I use that value (it's the value I get from GetInfo(212), which prints cleanly, and I believe is utilizing font size 9, but I am not 100% sure!). | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #7 on Thu 11 Jul 2024 08:11 PM (UTC) |
Message
| The so-called font size is in points (so 9 is a 9-point font) but the height is in pixels. Thus you have to use the suggested code (WindowFontInfo) to find the amount of vertical height taken by the font, in pixels. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #8 on Fri 12 Jul 2024 05:07 AM (UTC) |
Message
| The selector DefaultOutputFontHeight is probably poorly named. It should be DefaultOutputFontSize rather than height.
I think I might have got a bit confused myself about the difference when I wrote that stuff. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #9 on Fri 12 Jul 2024 05:12 AM (UTC) |
Message
| Maybe GetInfo (241)?
Quote:
241 - The height, in pixels, of a character in the output window, in the current output font.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
2,079 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top