Page 3 of 3

Re: 1556 / New font installation?

Posted: Thu Feb 22, 2018 4:08 am
by Vadi
Yep, the font name will be the fonts name, not the file's name for sure. I am also pretty certain we can make it "just work" without making people go through the hassle of scripting the font loading. As already demonstrated in the Mudlet community, having to script things does not work too well - not many scripts delete their UI elements or restore the window borders on a script uninstall, for example.

So, we need to make this as easy and hassle-free as possible and atm I'm not seeing any limitation to it. Scan the list of files in a package, install any font files you find, done.

Re: 1556 / New font installation?

Posted: Thu Feb 22, 2018 2:02 pm
by SlySven
The algorithm is a bit more than that I think:
  1. Scan the list of files in a package - the new module install code does that already to pick out the sub-directories it may need to create first - so that is not a problem - but what makes something a font file - is it just a .otf or .ttf file extension?
  2. Install any font files found:
    1. What if the file is already in the system? - I guess it goes in silently - as we are probably already doing that for the ttf-bitstream-ver-1.10 files we bundle - although, for instance, my Debian "Stretch" already has a system provided 1.10-8 - I guess the application font the Mudlet version becomes silently supplants the system one.
    2. What happens if the font has already been loaded as an application one by another profile or module? Either subsequent loads will fail or will supplant the previous one. Unfortunately it is not clear whether we can determine what a font will be called internally from the filename presented to be loaded. The only indication whether a particular application font loading being successful is a non-(-1) ID return value from the method used, it is not clear that that ID has much use other than to allow the font to be unloaded again. I guess we could note the base name of the filename used to load each font in the FontManager class and cross check new requests against the ones already loaded so as to skip obvious duplicates - some experimentation is needed methinks.
Actually that last point suggests that a module may be always be able to call for a font to be loaded from within it's archive file and it may be possible to just silently ignore it if already loaded...

Re: 1556 / New font installation?

Posted: Thu Feb 22, 2018 2:05 pm
by Nyyrazzilyss
Vadi wrote:
Thu Feb 22, 2018 4:08 am
So, we need to make this as easy and hassle-free as possible and atm I'm not seeing any limitation to it. Scan the list of files in a package, install any font files you find, done.
That would work really well to: If the package installer were to copy any included .ttf files into the fonts directory/load the font.

If I need a specific font while creating a script, I can copy it to the correct load location/restart mudlet myself. It's more a problem when it comes to distribution of the completed package.

Re: 1556 / New font installation?

Posted: Tue Feb 27, 2018 5:16 pm
by Nyyrazzilyss
Something useful going with this might be a command like 'getFonts()' that returned a table with a list of names of installed fonts.

Re: 1556 / New font installation?

Posted: Tue Feb 27, 2018 5:47 pm
by SlySven
That may problematic as I see it, as I am not sure that Qt actually provides that information in an easy to get at form for fonts that come as part of the system/OS compared to loaded in by Mudlet itself...

Re: 1556 / New font installation?

Posted: Tue Feb 27, 2018 5:52 pm
by Vadi
Should be possible, there is an entire class dedicated to it: https://doc.qt.io/qt-5/qfontdatabase.html

Re: 1556 / New font installation?

Posted: Tue Feb 27, 2018 7:44 pm
by Nyyrazzilyss
Looking at the Qt class, something like that could be helpful.

In playing with fonts, i've re-written my gui to not use pre-built .png files, but instead create all the buttons/etc realtime from a table. This allowed me to give users a single command (@set font xxx + similar settings for colours used) to have the entire gui rebuild (excluding the mud text) itself to a different font. The user having to know the font names though is a bit difficult.

Re: 1556 / New font installation?

Posted: Tue Feb 27, 2018 11:30 pm
by SlySven
@Vadi I sit corrected (it's more comfortable than standing...) QtFontDatabase does operate on both loaded and system fonts - the previous stuff I was going on about is just the facet that deals with supplementing the system provided ones...

{Aside - as I found out with the room symbol letter we could improve the map text labels by not storing a small point size font bitmap and scaling it to fit but instead using as big a font as necessary to fit either the specified map label size or perhaps just using a fixed large size and allowing that to be scaled down...}

Re: 1556 / New font installation?

Posted: Sat May 26, 2018 4:28 am
by Vadi
@Nyyrazzilyss: I've added font support for the next Mudlet. Just add your font file to the package and you can automatically use it :) test it out for me: https://ci.appveyor.com/api/buildjobs/h ... mudlet.zip