qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.62k stars 3.01k forks source link

QGIS Server: Wrong Font display #30270

Closed freedom7979 closed 4 years ago

freedom7979 commented 5 years ago

Describe the bug

In QGIS Server, fonts are poorly displayed on Windows. This is how it looks in QGIS - font Times New Roman Label in QGIS This is how it looks label from QGIS Server by WMS - font is unknown for my and wrong char "ě" Label from QGIS Server by WMS

How to Reproduce

  1. Create virtual directory on IIS with setting in

c:\Windows\System32\inetsrv\Config\applicationHost.config

<add name="QGISServer" autoStart="true" enable32BitAppOnWin64="false" managedRuntimeVersion="">
<processModel identityType="SpecificUser" userName="user" password="pass" />
<environmentVariables>
<add name="PATH" value="C:/OSGeo4W64/apps/Python37;C:/OSGeo4W64/apps/Python37/Scripts;c:/OSGeo4W64/bin/gdalplugins;c:/OSGeo4W64/apps/Qt5/bin;C:/OSGeo4W64/bin;C:/OSGeo4W64/apps/qgis/bin;C:/OSGeo4W64/apps/grass/grass-@grassversion@/bin;C:/OSGeo4W64/apps/grass/grass-@grassversion@/lib;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem" />
<add name="QT_QPA_FONTDIR" value="c:/Windows/Fonts" />
<add name="QGIS_PREFIX_PATH" value="C:/OSGeo4W64/apps/qgis" />
<add name="QT_PLUGIN_PATH" value="C:/OSGeo4W64/apps/qgis/qtplugins;C:/OSGeo4W64/apps/qt5/plugins" />
<add name="TEMP" value="C:/Users/Svoboda/AppData/Local/Temp" />
<add name="PYTHONHOME" value="C:/OSGeo4W64/apps/Python37" />
<add name="PYTHONIOENCODING" value="UTF-8" />
<add name="GDAL_DATA" value="C:/OSGeo4W64/share/gdal" />
<add name="GDAL_DRIVER_PATH" value="C:/OSGeo4W64/bin/gdalplugins" />
<add name="QGIS_SERVER_LOG_FILE" value="C:/OSGeo4W64/apps/qgis/bin/qgis_mapserv.fcgi.log" />
<add name="QGIS_SERVER_LOG_LEVEL" value="0" />
<add name="QGIS_SERVER_PARALLEL_RENDERING" value="true" />
<add name="QGIS_SERVER_MAX_THREADS" value="2" />
<add name="LC_ALL" value="cs_CZ.UTF-8" />
<add name="LANG" value="cs_CZ.UTF-8" />
<add name="QGIS_OPTIONS_PATH" value="c:/Users/Svoboda/AppData/Roaming/QGIS/QGIS3/profiles/default/" />
<add name="QGIS_SERVER_CACHE_DIRECTORY" value="c:/Windows/Temp" />
</environmentVariables>
</add>
  1. Set web.config in

c:\OSGeo4W64\apps\qgis\bin\web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers accessPolicy="Read, Execute, Script">
<add name="qgis" path="*.exe" verb="*" modules="FastCgiModule" scriptProcessor="C:\OSGeo4W64\apps\qgis\bin\qgis_mapserv.fcgi.exe" resourceType="File" requireAccess="Execute" />
</handlers>
</system.webServer>
</configuration>
  1. Invoke URL for WMS service

    Additional context How QGIS Server is looking for fonts is a mystery to me.

jgrocha commented 5 years ago

QGIS (and QGIS Server) should use the fonts installed on the machine.

If the machine where you prepare the project is different from the server, you might have that problem. But if you are using the same machine, you should have the same font available in QGIS and in QGIS Server.

Are you running QGIS Server on the same machine where you prepared the project? Or your QGIS desktop is different from your QGIS Server? Do you have access to the server and can you check if the font is installed on the server?

freedom7979 commented 5 years ago

I'm running QGIS Server and QGIS on the same machine. Please have you an idea way QGIS Server did not find fonts? Thank you very much for your reply.

gioman commented 5 years ago

I'm running QGIS Server and QGIS on the same machine. Please have you an idea way QGIS Server did not find fonts? Thank you very much for your reply.

regardless of the WMS client? have you tried with another font?

freedom7979 commented 5 years ago

regardless of the WMS client? have you tried with another font?

In different WMS clients the result is the same. I used different fonts and the result is the same.
It seems to be using the same font regardless of the setting. Other settings seem to respect size, color, bold, and so on.

gioman commented 5 years ago

In different WMS clients the result is the same. I used different fonts and the result is the same. It seems to be using the same font regardless of the setting. Other settings seem to respect size, color, bold, and so on.

any chance you can test your project and service using qgis server on another platform... say for example Ubuntu (there are plenty of VMs/containers can be used)?

freedom7979 commented 5 years ago

any chance you can test your project and service using qgis server on another platform... say for example Ubuntu (there are plenty of VMs/containers can be used)?

I certainly can, but I'd rather use IIS on Windows. Is there any chance that it will ever work on IIS? Other features work fine :) and issue with the fonts are last thing for my satisfaction. Thank you very much for your reply.

jgrocha commented 5 years ago

@freedom7979 Take a look at this email thread http://osgeo-org.1560.x6.nabble.com/QGIS3-Server-on-Windows-Server-and-IIS-td5404369.html

At the end Kasper refers to a specific problem with fonts in Windows and how to solve the issue (with a QGIS Server plugin).

I've just copied and paste here:

BTW, there is a problem with fonts in this version.
See the fontloader example at 
https://github.com/avinet/qgis-server-font-loader
<https://github.com/avinet/qgis-server-font-loader>  , add it to the plugins
and  point it to the windows font directory.
freedom7979 commented 5 years ago

I try qgis-server-font-loader, but this plugin for version 2.5-2.99. I remove qgisMaximumVersion=2.99 from metadata.txt, so he could at least try to load. But plugin loaded with error:

13:15:21 INFO ..\..\..\src\server\qgsserverplugins.cpp[4048]: Python support library loaded successfully.

13:15:21 WARNING Python error[4048]: Traceback (most recent call last): File "C:\OSGeo4W64\apps\qgis/./python\qgis\utils.py", line 591, in startServerPlugin server_plugins[packageName] = package.serverClassFactory(serverIface) File "C:/Users/Svoboda/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis-server-font-loader\__init__.py", line 4, in serverClassFactory from FontLoader import FontLoaderServer File "C:\OSGeo4W64\apps\qgis/./python\qgis\utils.py", line 686, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'FontLoader' 13:15:21 WARNING Couldn't load server plugin qgis-server-font-loader due to an error when calling its serverClassFactory() method[4048]: Couldn't load server plugin qgis-server-font-loader due to an error when calling its serverClassFactory() method

ModuleNotFoundError: No module named 'FontLoader'

Traceback (most recent call last): File "C:\OSGeo4W64\apps\qgis/./python\qgis\utils.py", line 591, in startServerPlugin server_plugins[packageName] = package.serverClassFactory(serverIface) File "C:/Users/Svoboda/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis-server-font-loader\__init__.py", line 4, in serverClassFactory from FontLoader import FontLoaderServer File "C:\OSGeo4W64\apps\qgis/./python\qgis\utils.py", line 686, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named 'FontLoader'

Plugin doesn't solve my trouble

jgrocha commented 5 years ago

Duplicated of #29244

tm261700 commented 5 years ago

I have the same problem

freedom7979 commented 4 years ago

QGIS Server started working in version 3.10.0-3. Respectively, he began to respect variable QT_QPA_FONTDIR in Web.config. Thank you for fixing the bug! The picture shows diacritics: 2019-12-02_9-07-28