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

[Bug]: Warning Font "Helvetica" not available on system in QGIS >=3.22 #515

Closed
MattF-NSIDC opened this issue Apr 24, 2023 · 5 comments · Fixed by #522
Closed

[Bug]: Warning Font "Helvetica" not available on system in QGIS >=3.22 #515

MattF-NSIDC opened this issue Apr 24, 2023 · 5 comments · Fixed by #522
Assignees
Labels
bug Something isn't working
Milestone

Comments

@MattF-NSIDC
Copy link
Member

Issue description

From: QGR-134

TODO: Is the version specification correct? Maybe started in 3.18?

In older versions of QGIS, the error may manifest in a less visible way like this:

image

In newer versions, the error is surfaced to the viewport:

image

Workaround

Install helvetica.ttf (TODO: Find a safe source)

Proposed solution

Require minimum version of QGIS 3.28, which is capable of downloading missing fonts. Pick an open source font that will be used on all operating systems.

Commentary

Matt Fisher

Found this issue on GitHub: qgis/QGIS#46206

Looks like this warning was promoted from being hidden in the symbology menu to the main viewer, but it's still just a warning. I think we need:

Add a note about this to troubleshooting docs
If possible, select a default font for the whole project that is available in all major OSes to minimize the occurrence of the warning.

Trey Stafford

The "Helvetica" font seems to be set in the project file (qgreenland.qgs). I manually did a global replacement of all occurrences of "Helvetica" with "Sans Serif", which resolved the issue when opening the project in QGIS.

Unclear how this attribute gets set. It might be the QT library that's determining a default system font? Perhaps Helvetica is available in the docker image that we use to generate the project file?

I tried getting the default font using the PyQT library but was unsuccessful:

(base) root@1bfc695b3a88:/luigi# python
Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:23:14) [GCC 10.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtGui import QFont
>>> QFont().defaultFamily()
Segmentation fault (core dumped)
(base) root@1bfc695b3a88:/luigi#

System information

  • Operating system: Any except Windows
  • Operating system version: Any
  • QGIS version: >=3.22
  • QGreenland version: Any
@MattF-NSIDC MattF-NSIDC added the bug Something isn't working label Apr 24, 2023
@MattF-NSIDC MattF-NSIDC added this to the QGreenland v3 milestone Apr 24, 2023
@MattF-NSIDC MattF-NSIDC self-assigned this May 1, 2023
@MattF-NSIDC MattF-NSIDC changed the title [Bug]: "Warning - Helvetica font not found" in QGIS >=3.22 [Bug]: Warning Font "Helvetica" font not available on system in QGIS >=3.22 May 3, 2023
@MattF-NSIDC
Copy link
Member Author

Perhaps Helvetica is available in the docker image that we use to generate the project file?

I think I've ruled that out using fc-list in the container. Helvetica is not there, nor is it on my system.

@MattF-NSIDC
Copy link
Member Author

Ruled out style data in the GeoPackage by loading it outside of QGreenland and receiving no warning.

@MattF-NSIDC
Copy link
Member Author

MattF-NSIDC commented May 3, 2023

With a breakpoint at the end of make_map_layer:

from qgis.core import QgsReadWriteContext
from PyQt5.QtXml import QDomDocument

domdoc = QDomDocument()
ctx = QgsReadWriteContext()
map_layer.exportNamedStyle(domdoc, ctx)

'Helvetica' in domdoc.toString()

Results in True after the _load_qml_style function is called, but False before.

@MattF-NSIDC
Copy link
Member Author

MattF-NSIDC commented May 3, 2023

🎉 progress!

I'm testing with one layer that uses the qgreenland/ancillary/styles/transparent_labeled_shape.qml style. In that style file, there's an XML attribute fontFamily="Sans Serif". This seems to be translated to Helvetica when we call map_layer.loadNamedStyle(...) and that's reflected in qgreenland.qgs. I don't know why this would happen on a Linux system that doesn't have Helvetica available. The string helvetica does show up in the QGIS source code, which could be the cause.

If I change the style .qml file to read fontFamily="Open Sans", then qgreenland.qgs does not contain any mention of Helvetica and the warning does not occur on opening the project.

This sounds possibly like a bug should be opened against the QGIS project.

@MattF-NSIDC MattF-NSIDC changed the title [Bug]: Warning Font "Helvetica" font not available on system in QGIS >=3.22 [Bug]: Warning Font "Helvetica" not available on system in QGIS >=3.22 May 3, 2023
@MattF-NSIDC
Copy link
Member Author

qgis/QGIS#53012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant