Bold (or other style) part of a feature label in QGIS

conditionallabelingqgis

I'm working on a map in QGIS (3.16.11-Hannover) and have a feature label that's generated from three attributes as follows:

"Site name"   || ', ' ||  "When" ||   '\n'   || "Comment" 

I'd like to bold and/or underline the first line (i.e. the two attributes "Site name" and "When") as a sub-heading, but leave the rest (the "Comment" attribute, which is a relatively long description in this case) unbolded. Is there a way to do this or can I only bold the whole heading or not at all.

I tried setting this up in the bold formatting by field dropdown (see below), but this seems to bold the entire label when it contains the text in that field, which is not what I want.

screenshot of bold formatting by field dropdown

I did come across this similar question here but I believe that's to allow only some labels in a feature to be bolded, rather than only one part of the label for every feature.

By the way, I'm aware that putting this much text on a map usually isn't great design but I think what I'm trying to do here is a legitimate exception!

Best Answer

Possible workaround:

Duplicate your layer. Label the original layer with the name of the site in bold. Label the second layer with your other attributes in normal script, start the label with an empty row. Use identical, fixed label placements for both layers. Finally, turn off the symbology on the duplicated layer.

You could also look into text markers as symbology.