8

I just updated qgis-server package to latest 3.2.x from Ubuntugis repository (ubuntugis-unstable) and everything works fine - but font rendering. All labels on tiles, legend and print templates show up as squares:

enter image description here

After upgrading I got a lot of this messages in nginx error log:

QFontDatabase: Cannot find font directory /usr/lib/x86_64-linux-gnu/fonts - is Qt installed correctly?

I could fix that by adding a symbolic link from /usr/lib/x86_64-linux-gnu/fonts to /usr/share/fonts and updating font cache with fc-cache -fv. But this brought no changes to visualization of labels.

The QGIS project uses Ubuntu font installed from ttf-ubuntu-font-family package and shows up fine on QGIS Desktop. The font is also listed on the server using fc-list.

There are no error messages related to fonts neither in nginx error log nor in QGIS Server logging. Could be related to Qt so, any hints?

  • 2
    I think that you need to set up the environment variable,export QT_QPA_FONTDIR=<path to font files> for example export QT_QPA_FONTDIR=/usr/share/fonts/open-sans – Fran Raga Jul 6 '18 at 10:49
  • Thanks for the hint, QT_QPA_FONTDIR is the key. It doesn't work exporting it as environment variable, at least when using fastcgi you have to do something like fastcgi_param QT_QPA_FONTDIR "/usr/share/fonts/open-sans"; (nginx) or SetEnv QT_QPA_FONTDIR /usr/share/fonts/open-sans (apache). – geraldo Jul 6 '18 at 13:58
5

I put my comment as an answer:

You need to set up the environment variable,export QT_QPA_FONTDIR=<path to font files> for example export QT_QPA_FONTDIR=/usr/share/fonts/open-sans

But when using fastcgi you have to do something like: @geraldo

nginx

fastcgi_param QT_QPA_FONTDIR "/ usr / share / fonts / open-sans"

apache

SetEnv QT_QPA_FONTDIR / usr / share / fonts / open-sans .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.