Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts are not loaded correctly with qwc-qgis-server since version 3.28.6 #6

Closed
danceb opened this issue Jul 20, 2023 · 10 comments
Closed

Comments

@danceb
Copy link

danceb commented Jul 20, 2023

To include additional fonts, change the locale and other things I am building an own qwc-qgis-server image based on yours. Since the Dockerfile and entrypoint.sh files are changed plainly, I had to rewrite our files as well to work with the current versions of qgis server.
Unfortunately I don't get the fonts work properly. They are used within GetMap requests and also on the print templates in a correct way. But in the legendGraphics the font is not used and I am getting the following error within the logs:

QFont::fromString: Invalid description '(empty)'
QPainter::scale: Painter not active

Any hints, where this could come from?

My Dockerfile:

FROM sourcepole/qwc-qgis-server:3.28.8

RUN apt-get update \
    && apt-get install --no-install-recommends -y cifs-utils \
    && rm -rf /var/lib/apt/lists/*

ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8

# ENV variables that will be used to configure QGIS server FCGI
[...]
# Add apache config for QGIS server
ADD qgis3-server.conf.template /etc/apache2/templates/qgis-server.conf.template

# Add font and plugins folders
ADD fonts /usr/local/share/fonts
ADD plugins /usr/share/qgis/python/plugins

RUN fc-cache -f && fc-list | sort

# Add entrypoint
COPY entrypoint.sh /entrypoint.sh

EXPOSE 80

VOLUME ["/data"]

ENTRYPOINT ["/entrypoint.sh"]

My entrypoint.sh

#!/bin/bash
set -e

echo "Mounting cifs volume QGIS..."
mkdir -p [...]
mount -t cifs [...] -o user=${QGIS_CIFS_USER},password=${QGIS_CIFS_PASSWORD},domain=,uid=0,iocharset=utf8,vers=2.1,noperm,noserverino
echo "QGIS cifs mount successful!"

# Substitute variables from ENV
envsubst < /etc/apache2/templates/qgis-server.conf.template > /etc/apache2/sites-enabled/qgis-server.conf

# Activate the Ubuntu Apache environment
. /etc/apache2/envvars

exec /usr/sbin/apache2 -k start -DFOREGROUND

Any ideas would be very helpful, thanks!

@danceb
Copy link
Author

danceb commented Jul 31, 2023

I modified the comment above, because the mounts of the fonts and plugin folders where not correctly. Changed it to the folders mentioned in the readme, but still getting the same errors.

I tried to set the environmental variable FcgidInitialEnv QT_QPA_FONTDIR "/usr/local/share/fonts" within qgis-server.conf.template related to qgis/QGIS#51688, but this doesn't change anything.

How can we detect, if this is a issue which comes from the qgis server itself or from the adjustments made while building a custom image based on it?

@manisandro
Copy link
Member

@HusseinKabbout Any ideas?

@danceb danceb changed the title Fonts are not loaded correctly with custom build of qwc-qgis-server image Fonts are not loaded correctly with qwc-qgis-server since version 3.28.6 Jul 31, 2023
@danceb
Copy link
Author

danceb commented Jul 31, 2023

To simplify the test case more, I left over my own building attempts with a custom Dockerfile and entrypoint.sh and just pulled your image and configured it within the docker-compose.yml and mount the font folder there:

  qwc-qgis-server:
    image: sourcepole/qwc-qgis-server:3.28.6
    restart: unless-stopped
    volumes:
      - ./volumes/qgs-resources/stage:/data:ro
      - ./volumes/geodata/stage:/geodata:ro
      - ./pg_service.stage.conf:/etc/postgresql-common/pg_service.conf:ro
      - ./qwc-qgis-server/fonts:/usr/local/share/fonts
    cap_add:
      - SYS_ADMIN
      - DAC_READ_SEARCH
    security_opt:
      - apparmor=unconfined

until 3.28.5 the legend is generated correctly with the mounted custom font and since 3.28.6 this does not work anymore.

@danceb
Copy link
Author

danceb commented Aug 21, 2023

@HusseinKabbout Any (new) thoughts about this?

@pka
Copy link
Member

pka commented Aug 21, 2023

The fonts are listed when starting the container. Are your additional fonts missing in the output? Latest LTR version is 3.28.10.

@danceb
Copy link
Author

danceb commented Aug 21, 2023

Yes, the custum font is listed correctly, Arial in my case:

qwc-qgis-server_1              | /usr/local/share/fonts/Arial.ttf: Arial:style=Standard,Normal,obyčejné,Κανονικά,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,thường,Arrunta

So the mounting seems to work.

But this is a sample legend image with 3.28.5:
grafik

And this what it lools like with a newer version (3.28.10 here):
grafik

So the custom font is not used for creating the legend image.

@pka
Copy link
Member

pka commented Aug 21, 2023

Could you try to mount the custom fonts in /usr/share/fonts/truetype instead?

@pka
Copy link
Member

pka commented Aug 21, 2023

Looking at the legend output in the given resolution, I can't spot a difference in the font. Are you sure, that not only the font size differs?

@danceb
Copy link
Author

danceb commented Aug 21, 2023

Thats exactly the thing I recognized at this moment. I think the standard font size of the getLegendGraphics request from qgis server has changed and this result in confusing me ...
So everything should be fine here.

@danceb danceb closed this as completed Aug 21, 2023
@danceb
Copy link
Author

danceb commented Aug 21, 2023

I specified the correct font now via the extraLegendParameters in the config.json and it is loaded correctly.

However I am getting QFont::fromString: Invalid description '(empty)' within the log, but this is not related to this issue here, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants