PDA

View Full Version : Adding new fonts without need to reboot


Penguin
2014-01-16, 17:20
I have tried to find out how a new font can be installed into SailfishOS so that Qt/Qml app can use it without need to reboot device after font installation.

In my desktop linux (Ubuntu) I only have to copy font files to ~/.fonts or to system font directories and it it automatically recognized. E.g. font substitution works automatically. Sailfish does not recognize fonts from users .fonts directory but only from under /usr/share/fonts and only after reboot I have been able to get new font into use. Removal is immediate and visible in application using the font without any delay.

Is there some command that needs to be executed before new fonts are recognized?

shmerl
2014-01-16, 23:43
Will restarting the lipstick read those fonts? It's still pretty drastic, but at least should be faster than a full reboot.

Penguin
2014-01-17, 01:33
It does the job, but I can't initiate that from RPM post install script. Until finding some more sophisticated way to do this I'll have to instruct manual reboot.

javispedro
2014-01-17, 01:46
The problem is most definitely NOT lipstick. Lipstick doesn't load any fonts. In Wayland programs are supposed to load fonts. Same as in modern X11, with Qt/Gtk+/fontconfig.

I suspect this is a problem with mapplauncherd, it is probably scanning for fonts before the fork() and not doing it afterwards. So every application gets the font set applauncherd got.

Maybe you can use something like
http://qt-project.org/doc/qt-5.0/qtgui/qfontdatabase.html#addApplicationFont
in order to manually add the font in your program.

J4ZZ
2014-01-17, 11:59
How about good old
fc-cache -f -v

This should refresh the font cache on the fly.

Penguin
2014-01-18, 18:38
This need for updating fonts is related to emoji keyboard I have created for Jolla. As "the app" it is just QML files for keyboard I am not sure about this font loading.

I have tested with fc-cache and actually I found only "fc-cache -r" to be only reliable solution to get font updated even when I reboot device. More mild option "fc-cache -f" didn't to do its job in some very minor font updates. I do not know why.