Murga-Projects Forums

Full Version: Font handling improved in 0.6.8, but...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Recently I started playing with using LUA_INIT to customize the look of murgaLua interfaces (sort of "themeing"). In short, if you have the environment variable LUA_INIT pointing to a lua script, the commands in that script will be run when murgaLua starts.

I noticed that with the release of 0.6.8, font handling has improved quite a bit, at least for X fonts in Linux. Thank you for this, John.

Previous versions would not properly set fonts from a LUA_INIT file using Fl:set_font(font_name,new_font)...I kept getting 'fixed' instead of the desired font. Now it works properly. But there are a couple of odd things that I can't understand.

Below is a post from the DSL forums, so I don't have to bother typing it again:

I tried this script to see what fonts are available:

Code:
numfonts=Fl:set_fonts()
for i=0,numfonts do
print(Fl:get_font_name(i)) end

Every font that had been set in LUA_INIT printed what appears to be garbage.
After fooling around a little more I found that using the command Fl:get_font_name(0) in LUA_INIT would cause FL_HELVETICA to print the appropriate name of the font I had set.

However, if I moved that command from LUA_INIT to the script, it didn't work anymore.

So apparently, in order for scripts to retrieve the appropriate font name, you must retrieve in within LUA_INIT, after the font has been set:

Code:
Fl:set_font(4,"terminus")
Fl:set_font(0,"smooth")
for i=0,15 do Fl:get_font_name(i) end

I did it for all 16 fonts in one go just so I don't have to bother with it again in the future.

A couple more notes:
Regardless of the above issue, murgaLua 0.6.8 now handles X font names much better than it did before. In the fonts-system demo in the murgaLua demos package the X font names would be rather messy (-*-fixed-medium-r-normal--*, for example). Now it simply uses the name "fixed". If you attempt to use "-*-terminus-*" now, instead of just "terminus", the result can be a bit unpredictable.

Also, murgaLua *tries* to apply bold/italic using the same custom font, apparently, but if you don't have bold/normal versions of that font installed you also get unpredictible results. It seems that FLTK just picks something that it thinks resembles what you want.

Reference URL's