main output font in MUSHclient folder not loading at startup?

Posted by Fiendish on Wed 29 May 2019 03:48 AM — 13 posts, 46,593 views.

USA Global Moderator #0
If I set my output font to be Dina loaded from the MUSHclient folder instead of one of the system installed fonts, when I start up MUSHclient it refuses to actually use the font until I open the world settings and pop open the font selector and then hit ok.
Australia Forum Administrator #1
I can't even see in the code what might enable that behaviour. Perhaps use AddFont in world startup?

Template:function=AddFont
AddFont

The documentation for the AddFont script function is available online. It is also in the MUSHclient help file.

USA Global Moderator #2
Well it's definitely shown as an option when I go to select my output font. And I can choose it, and the setting sticks. It just doesn't work. ¯\ _(ツ)_/¯
Amended on Sat 01 Jun 2019 01:59 AM by Fiendish
Australia Forum Administrator #3
What is shown as an option? I'm surprised that it works at all.
USA Global Moderator #4
Quote:
What is shown as an option?

The Dina font. See: https://i.imgur.com/CX5Yxeb.png
Amended on Sat 01 Jun 2019 04:43 PM by Fiendish
Australia Forum Administrator #5
Yes, but the font configuration dialog doesn't have any code to load fonts from your current folder. Windows must be doing that.
USA Global Moderator #6
Ok but that aside, why does MUSHclient happily load the local Dina font when I choose it but then not load the font at startup until I go and choose it again?
USA Global Moderator #7
Let's say one of my plugins is adding Dina (they are) and then a user seeing it as an option decides to set it as their main output font.

Is it possible for AddFont to try to run automatically if the world output setting at launch indicates a font that isn't in the MUSHclient space?
Amended on Fri 10 Apr 2020 05:35 AM by Fiendish
USA Global Moderator #8
Also, something isn't working right here when I try to do it manually.


Loading this plugin does not update the font display as I would expect:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="Dina_test"
   author="Fiendish"
   id="0399d8b2259be90d8a4c3442"
   language="Lua"
   requires="4.00"
   version="1.0"
   >
</plugin>

<script>
<![CDATA[
   AddFont(GetInfo(66).."Dina.fon")
   SetAlphaOption("output_font_name", "Dina")
   SetOption("output_font_height", 10)
   SetOutputFont("Dina", 10)
   Repaint()
]]>
</script>
</muclient>


The font only updates if I open the output font configuration dialog and re-save the current setting.


See this screen recording: https://youtu.be/cWxxuQoO8QA
Amended on Sat 11 Apr 2020 07:54 PM by Fiendish
Australia Forum Administrator #9
I can't reproduce that. I tried on Ubuntu Wine and Mac with Crossover Wine. In both cases your plugin worked.

You need to give more details. Exactly what version of MUSHclient, and what operating system (including version of Wine) are you using?
USA Global Moderator #10
I have a new video for you: https://youtu.be/yLxsTrdrfr0

MUSHclient 5.07-pre and 5.06 at least.
macOS 10.14.6 with Wine 5.0 and 5.7 staging where everything else works fine.

Loading a world file that has output_font_name="Dina" and output_font_height="10" ( like this one: https://pastebin.com/raw/41jwn5RW ). This part I believe is key.

I cannot get the output to actually show using Dina 10 until I manually go into world settings and click OK on the font. I can get it to show Dina 8, but I believe that that's because the world file tried to load Dina 10 at startup and failed because Dina had not yet been added.

I think that if the world file specifies a font that doesn't yet exist because it has to be loaded first with AddFont, then MUSHclient should try to call AddFont to load it as the first fallback and then only use the wrong font if that fails. It would require storing the font file path and not just font name if the world font was loaded with AddFont.
Amended on Fri 29 May 2020 05:12 AM by Fiendish
USA Global Moderator #11
Even adding this code to the start of CMUSHclientDoc::SetUpOutputWindow doesn't work


  WIN32_FIND_DATA FindFileData;
  HANDLE hFind;
  CString app_dir = ExtractDirectory(App.m_strMUSHclientFileName);
  list<CString> font_globs {app_dir + "*.fon", app_dir + "*.ttf"};
  for (list<CString>::iterator fit = font_globs.begin(); fit != font_globs.end(); fit++) {
    hFind = FindFirstFile(*fit, &FindFileData);
    if (hFind != INVALID_HANDLE_VALUE) {
        do {
            AddSpecialFont(app_dir + FindFileData.cFileName);
        } while (FindNextFile(hFind, &FindFileData) != 0);
    }
  } 


I don't know what to try next.
Australia Forum Administrator #12
Sorry for the tardy response. My mind has boggled a bit due to other things happening in the world right now.

(The response is still tardy, I'll try to look at it shortly).