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.39k stars 2.98k forks source link

Label alignment issues when HTML formatting is enabled #50887

Open Sidapo opened 1 year ago

Sidapo commented 1 year ago

(edited to include further information)

What is the bug or the crash?

When HTML formatting is enabled & the label font size is set by a data defined override: Using <p> to break a line causes text alignment issues for all alignment types except Left. For example, this label is set to Right: image

Steps to reproduce the issue

  1. Enable HTML Formatting
  2. Enter a label value with <p> to create a line break
  3. Set the label font size by a data defined override (just setting a number is sufficient)
  4. Change label alignment to anything other than Left

Versions

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

QGIS version | 3.28.0-Firenze | QGIS code revision | ed3ad0430f -- | -- | -- | -- Qt version | 5.15.3 Python version | 3.10.6 GDAL/OGR version | 3.4.1 PROJ version | 8.2.1 EPSG Registry database version | v10.041 (2021-12-03) GEOS version | 3.10.2-CAPI-1.16.0 SQLite version | 3.37.2 PDAL version | 2.3.0 PostgreSQL client version | unknown SpatiaLite version | 5.0.1 QWT version | 6.1.4 QScintilla2 version | 2.11.6 OS version | Ubuntu 22.04.1 LTS   |   |   |   Active Python plugins osminfo | 0.7.1 MapsPrinter | 0.9 ORStools | 1.5.2 QuickOSM | 2.1.1 joinmultiplelines | Version 0.4.1 qgis-maptiler-plugin | 3.1.1 ViewshedAnalysis | 1.8 mmqgis | 2021.9.10 trail_elevation_stats | 0.2 batchvectorlayersaver | 0.9 QRectangleCreator | 0.3 loadthemall | 3.3.0 WalkingTime-master | 0.2 color_attribute | 0.2.1 qNote | 2.2 coordinate_capture | 0.2 qtiles | 1.7.1 processing_saga_nextgen | 0.0.7 qgis2web | 3.16.0 qmapshaper | 0.8.0 path_sorting | 0.3 geometric_attributes | 0.3 nominatim | 1.4.2 TerrainShading | 0.9.4 AppendFeaturesToLayer | 1.2.0 profiletool | 4.2.2 OpenTopography-DEM-Downloader | 1.0 geo_sim_processing | 1.2.0 quick_map_services | 0.19.32 pointsamplingtool | 0.5.4 rvt-qgis | 0.9.4 HCMGIS | 22.9.9 MagneticDeclination | 2.3.1 SRTM-Downloader | 3.1.17 sagaprovider | 2.12.99 processing | 2.12.99 MetaSearch | 0.3.6 grassprovider | 2.12.99 db_manager | 0.1.20 QGIS version 3.28.0-Firenze QGIS code revision [ed3ad0430f](https://github.com/qgis/QGIS/commit/ed3ad0430f) Qt version 5.15.3 Python version 3.10.6 GDAL/OGR version 3.4.1 PROJ version 8.2.1 EPSG Registry database version v10.041 (2021-12-03) GEOS version 3.10.2-CAPI-1.16.0 SQLite version 3.37.2 PDAL version 2.3.0 PostgreSQL client version unknown SpatiaLite version 5.0.1 QWT version 6.1.4 QScintilla2 version 2.11.6 OS version Ubuntu 22.04.1 LTS Active Python plugins osminfo 0.7.1 MapsPrinter 0.9 ORStools 1.5.2 QuickOSM 2.1.1 joinmultiplelines Version 0.4.1 qgis-maptiler-plugin 3.1.1 ViewshedAnalysis 1.8 mmqgis 2021.9.10 trail_elevation_stats 0.2 batchvectorlayersaver 0.9 QRectangleCreator 0.3 loadthemall 3.3.0 WalkingTime-master 0.2 color_attribute 0.2.1 qNote 2.2 coordinate_capture 0.2 qtiles 1.7.1 processing_saga_nextgen 0.0.7 qgis2web 3.16.0 qmapshaper 0.8.0 path_sorting 0.3 geometric_attributes 0.3 nominatim 1.4.2 TerrainShading 0.9.4 AppendFeaturesToLayer 1.2.0 profiletool 5.2.2 OpenTopography-DEM-Downloader 1.0 geo_sim_processing 1.2.0 quick_map_services 0.19.32 pointsamplingtool 0.5.4 rvt-qgis 0.9.4 HCMGIS 22.9.9 MagneticDeclination 2.3.1 SRTM-Downloader 3.1.17 sagaprovider 2.12.99 processing 2.12.99 MetaSearch 0.3.6 grassprovider 2.12.99 db_manager 0.1.20 ### Supported QGIS version - [X] I'm running a supported QGIS version according to the roadmap. ### New profile - [ ] I tried with a new QGIS profile ### Additional context _No response_
Sidapo commented 1 year ago

It seems to be related to my project somehow: When I drag the layers (incl. the style) to a new QGIS instance it renders the labels as expected. There are multiple layers that behave as described above in the QGIS project.

Sidapo commented 1 year ago

I think I found what triggers the bug: The misalignment occurs when a data defined override is set for the label size.

erydit commented 1 year ago

I confirm this bug. Incorrect label alignment and label background size when an expression is used to define text size. Снимок экрана_2022-11-25_15-24-21

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

Версия QGIS | 3.28.0-Firenze | Кодовая ветка QGIS | Release 3.28 -- | -- | -- | -- Версия Qt | 5.15.7 Версия Python | 3.10.8 Версия GDAL/OGR | 3.5.3 Версия PROJ | 9.1.0 Версия базы данных реестра EPSG | v10.074 (2022-08-01) Версия GEOS | 3.11.0-CAPI-1.17.0 Версия SQLite | 3.39.4 Версия PDAL | 2.4.3 Версия PostgreSQL | unknown Версия SpatiaLite | 5.0.1 Версия QWT | 6.2.0 Версия QScintilla2 | 2.13.3 Версия ОС | Manjaro Linux   |   |   |   Включенные модули Python processing_saga_nextgen | 0.0.7 valuetool | 3.0.15 OSMDownloader | 1.0.3 FreehandRasterGeoreferencer | 0.8.3 SRTM-Downloader | 3.1.17 osminfo | 0.7.1 AcATaMa | 22.10.23 quick_map_services | 0.19.32 maplibrary | 1.2 processing | 2.12.99 db_manager | 0.1.20 MetaSearch | 0.3.6 Версия QGIS 3.28.0-Firenze Кодовая ветка QGIS [Release 3.28](https://github.com/qgis/QGIS/tree/release-3_28) Версия Qt 5.15.7 Версия Python 3.10.8 Версия GDAL/OGR 3.5.3 Версия PROJ 9.1.0 Версия базы данных реестра EPSG v10.074 (2022-08-01) Версия GEOS 3.11.0-CAPI-1.17.0 Версия SQLite 3.39.4 Версия PDAL 2.4.3 Версия PostgreSQL unknown Версия SpatiaLite 5.0.1 Версия QWT 6.2.0 Версия QScintilla2 2.13.3 Версия ОС Manjaro Linux Включенные модули Python processing_saga_nextgen 0.0.7 valuetool 3.0.15 OSMDownloader 1.0.3 FreehandRasterGeoreferencer 0.8.3 SRTM-Downloader 3.1.17 osminfo 0.7.1 AcATaMa 22.10.23 quick_map_services 0.19.32 maplibrary 1.2 processing 2.12.99 db_manager 0.1.20 MetaSearch 0.3.6
erydit commented 1 year ago

Also, wrong alignment also appears in the map composer in the Text element.

erydit commented 1 year ago

The issue is still actual in 3.28.1