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.65k stars 3.01k forks source link

HTML theming in print composer changed on update #58387

Open spono opened 3 months ago

spono commented 3 months ago

What is the bug or the crash?

In the print composer I have a text box (HTML frame) which is evaluated as HTML , as follows:

<html>
<head>
<style>
h1 {text-align: center; font-size: 22px; font-family: “Times New Roman”;}
p {text-align: justify; font-size: 10px; font-family: “Times New Roman”;}
</style>
</head>
<body>
<h1>Tavola CI</h1>
<p><i>Carta degli interventi (scala 1:20'000).</i></p>
<br>
<p><b>Progetto:</b><br>"Revisione del Piano di Riassetto Forestale</p>
</body>
</html>

Its appearance changed after updating from 3.34.5 to 3.34.9 (as you can see in the pic below). I tried specifying margin-top:15px within h1 and this solved the problem...but -I guess- it means that something changed in the QGIS main code from one version and the other.

Here is a sample of the output PDFs (.5 above, .9 below):

composer

Steps to reproduce the issue

import the following layout file (created under QGIS 3.28): bug_layout.zip

Versions

QGIS version | 3.34.9-Prizren | QGIS code revision | cbbc7bdf -- | -- | -- | -- Qt version | 5.15.13 Python version | 3.12.4 GDAL/OGR version | 3.9.1 PROJ version | 9.4.0 EPSG Registry database version | v11.004 (2024-02-24) GEOS version | 3.12.2-CAPI-1.18.2 SQLite version | 3.45.1 PDAL version | 2.6.3 PostgreSQL client version | unknown SpatiaLite version | 5.1.0 QWT version | 6.2.0 QScintilla2 version | 2.14.1 OS version | Windows 10 Version 2009   |   |   |   Active Python plugins qfieldsync | v4.10.1 QuickOSM | 2.2.3 db_manager | 0.1.20 MetaSearch | 0.3.6 processing | 2.12.99 QGIS version 3.34.9-Prizren QGIS code revision [cbbc7bdf](https://github.com/qgis/QGIS/commit/cbbc7bdf) Qt version 5.15.13 Python version 3.12.4 GDAL/OGR version 3.9.1 PROJ version 9.4.0 EPSG Registry database version v11.004 (2024-02-24) GEOS version 3.12.2-CAPI-1.18.2 SQLite version 3.45.1 PDAL version 2.6.3 PostgreSQL client version unknown SpatiaLite version 5.1.0 QWT version 6.2.0 QScintilla2 version 2.14.1 OS version Windows 10 Version 2009 Active Python plugins qfieldsync v4.10.1 QuickOSM 2.2.3 db_manager 0.1.20 MetaSearch 0.3.6 processing 2.12.99 ### Supported QGIS version - [X] I'm running a supported QGIS version according to [the roadmap](https://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule). ### New profile - [X] I tried with a new [QGIS profile](https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles) ### Additional context _No response_
agiudiceandrea commented 3 months ago

Hi @spono, thanks for reporting. I've tested the provided HTML code using QGIS 3.34.5 and QGIS 3.34.9 on Windows 10 and I don't see any rendering difference either in the layout preview or the exported PDF. Please provide a project and exact steps and parameters with which the issue occurs.

spono commented 3 months ago

uff...it's the second issue I report in the last months that can't be reproduced on your (debuggers) side...according to your experience, might it be related to an "accumulation" of things/code after continued updating? I mean: the original installation was with 3.28.x and I usually update the point versions on a regular basis. Might it be useful sometimes to erase everything and proceed with a fresh install?

BTW the project is quite a complex one...I'll try to simplify it but it won't be in short time

agiudiceandrea commented 3 months ago

according to your experience, might it be related to an "accumulation" of things/code after continued updating?

@spono, not sure to understand. QGIS can use multiple independent user profile with separate plugins and settings and on Windows it is also possible to have multiple independent and separate QGIS versions installed at same time. Can you replicate the issue using a new project (and or a new user profile) with a new print layout containing only the "Label" item and the provided HTML code?

spono commented 3 months ago

might it be related to an "accumulation" of things/code after continued updating?

I meant: might it be that, updating frequently, some piece of code does not update properly leading to this unreproduceable bugs?

Can you replicate the issue using a new project (and or a new user profile) with a new print layout containing only the "Label" item and the provided HTML code?

no, in a blank layout everything looks working fine.

But I created a Label box in the original project and it seems to interpret correctly the spacing from top margin but shows issues with the font: it should be Times NR, as specified, but looks like a sort of Calibri. If in the <head> I remove the quotation marks in font-family: Times New Roman, it is interpreted correctly.

no_Times2

BTW, if it does not appear in a brand new project but it happens when opening the original project with a new profile...sounds like it is related to the project itself (created under 3.28). What else can I check to identify which element of the project creates this issue? Might it be that projects from different versions are interpreted in a different way depending on the QGIS version?

spono commented 3 months ago

@agiudiceandrea I updated the steps for reproducing the error and I think this time it should work.

agiudiceandrea commented 3 months ago

@spono, thanks for providing a layout template. Anyway it looks like the layout generated by such template is the very same either using QGIS 3.34.9 or 3.34.5 or 3.28.15

image

It looks like the affected "HTML farme" item has the "User Stylesheet" option active with the following value: body { margin: 0 0;line-height: 122%;color: rgba(0,0,0,1.0000);font-family: MS Shell Dlg 2;font-style: normal;font-weight: 400;font-size: 9.79939px;text-align: justify; } It seems to me the issue is due to the fact that both margin: 0 0 and line-height: 122% are present. If one of the two or both are removed from the stylesheet or the "User Stylesheet" option is not active, then the issue doesn't occur. Not sure if the behaviour is actually due to a bug or to an incorrect option set.

spono commented 3 months ago

mmm...you're right, I've never noticed that option...and actually it created issues only now. Was the feature added or defaulted to true recently? BTW, sorry to make you lose time for such a pretty silly thing.