[Qgis-user] Labeling: Allow HTML Formatting, text-size and map units

Nyall Dawson nyall.dawson at gmail.com
Fri May 17 00:49:08 PDT 2024


On Thu, 16 May 2024 at 23:51, chris hermansen via QGIS-User
<qgis-user at lists.osgeo.org> wrote:
>
> Thomas and list,
>
> On Thu, May 16, 2024, 06:39 Thomas Schüttenberg <thomas at qgis.de> wrote:
>>
>> Hi Chris,
>>
>> yes I tried that. Any css-unit I could think of as well as em, % and code-words (large). But only pt resulted in a visible change on the canvas.

We're a little constrained by the subset of css which the Qt library
supports. See https://doc.qt.io/qt-6/richtext-html-subset.html#css-properties

Unfortunately Qt CSS only supports font sizes in pt or px, not %. This
could be an enhancement which the QGIS project considers sponsoring in
Qt in future -- I can certainly see the limitation for a use case like
you describe!

Nyall


>>
>> Not sure if it is just not implemented or if it is a bug.
>
>
> So <sub>...</sub> works but <small></small> doesn't... That seems to be surprising behaviour.
>
> I can get that CSS style directives might not work the way one might hope (that often happens to me in other circumstances...)
>
> This is tempting me to experiment. Thanks for that!
>
>>
>> Thomas
>>
>> > chris hermansen <clhermansen at gmail.com> hat am 15.05.2024 21:00 CEST geschrieben:
>> >
>> >
>> > Thomas and list,
>> >
>> >
>> > On Wed, May 15, 2024 at 7:20 AM Thomas Schüttenberg via QGIS-User <qgis-user at lists.osgeo.org> wrote:
>> > > Ha!
>> > >  I found an other way around to do the trick, suitable for my use case at least:
>> > >
>> > >  1) increasing the (overall) text size setting on the text tab by 2/3
>> > >  2) putting only the attributes/text strings of the second and following lines between <sub>...</sub> tags, which renders them about 2/3 smaler, i.e. same as before.
>> > >
>> > >  The (reverse) result is a multi line label with the first line emphazised by its larger size! ;-)
>> > >
>> > >  "Bezeichnung" || '<p><sub>D ' || round("Deckelhohe",2) || '</sub></p><p><sub>S ' || round( "Sohlhohe" ,2) || '</sub></p>'
>> > >
>> > In your first note you mentioned:
>> >
>> > > But only pt (points) seams to work as the unit in this place, which gives a fixed size throughout all scales and does not respect the behavior of the map units with maximum scale setting.
>> >
>> > I suppose you tried style="font-size: 75%;" and maybe style="font-size: 0.75em;", and they did not work?
>> >
>> > I wonder if, besides <sub>...</sub>, you might have tried <small>...</small>?
>> > --
>> >
>> > Chris Hermansen · clhermansen "at" gmail "dot" com
>> >
>> > C'est ma façon de parler.
>
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


More information about the QGIS-User mailing list