TransWikia.com

QGIS Server labels encoding

Geographic Information Systems Asked by Alexander Novikov on October 5, 2021

I have a PostgreSQL database with "UTF-8" encoding which contains data in Russian language.
Each table of database loaded in QGIS as a PostGIS layer.
I want to show labels of objects on a map.

When I open .qgs file on my machine in QGIS 3.2.2 it works fine.
right work

But when I open it via QGIS Server 3.2.2 on dedicated machine I have empty squares instead of text.

wrong

Both machines work under Windows 10 (English)

What the problem could be?

Update1:
I’ve also installed QGIS 3.2.3 on my dedicated machine. Russian text also doesn’t work there. May this problem be in Apache configuration?

Update2:
I’ve created another win-1251 database. It also doesn’t work.

One Answer

I figured out a solution for this problem which turned out to be kind of a multi-level problem requiring a multi-level solution:

Stage 1: Apparently a QGIS-Server that is running on a Windows OS is not able to resolve the system's font directory in the same way QGIS-Desktop is. Setting QT_QPA_FONTDIR did also not do the trick. As I'm using a QGIS-Server with some modifications anyway and have a working build-system ready to go i made some additions to the server's bootstrapping code, allowing for the specification of a font directory by means of a FCGI variable. The specified directory is then searched for all importable fonts which are added to the server's font database.

Stage 2: After adding the fonts configured in the label settings of my QGIS project to the font directory the missing labels still did not appear at first. The labels in my project are all attribute based and the font selected for rendering them is the common enough Arial. Eventually it turned out that the label attributes contained some special characters which are not present in the Arial character table. In such cases the underlying QT font rendering engine apparently searches through all available fonts, picks the first one supporting the requested character and uses it for rendering the character, while the rest of the label is rendered in Arial. In order to find out which supplemental font is used by QGIS-Desktop i copied a label from the preview box in the layer's property window to MS Word which upon selecting the special character indicates in the font picker tool which font is used. After copying that font to the server's font directory as well - at long last - the server is able to render all labels correctly!

Granted this is not the cleanest solution (being able to use QT_QPA_FONTDIR without any modifications to the server code for example would of course be preferable)... it IS a solution for now.

Answered by Edward Ministrator on October 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP