TransWikia.com

How to create a label combining different font sizes or types?

Geographic Information Systems Asked on September 3, 2021

I would like to place the elevation-number of a point in a different front size and centred under its name:

enter image description here

Is that possible?

(That is my actual labeling: label || 'n' || elevation)

5 Answers

Ignoring font size for the minute, you could achieve your first option by centering the label above the point, in QGIS 1.9 you have the option to center the text under the multiple lines section. If you have included a newline character in your expression you can leave the 'Wrap on character' box empty (or I put a slash in my expression instead of the 'n' and set that as the wrap-character - the wrap-character isn't shown). This will set your text centered as in your second option. For something like your first option, you could set the line height option to 2 or 3.

However, QGIS advanced labeling only has a single option for font size. So, to achieve the different font sizes, I think you will have to add your layer a second time and set the elevation font and position in there.

Answered by MappaGnosis on September 3, 2021

Unfortunately, this is not possible yet. For a related recent discussion check http://osgeo-org.1560.x6.nabble.com/HTML-tags-in-label-expresion-on-QGIS-2-0-1-td5084946.html.

There is also an existing feature request.

Answered by underdark on September 3, 2021

You can achieve what you want using Rule-Based Labeling, but you need to separate the labels located in one field into two fields. Rule-Based Labeling option enables you to add labels from different fields and customize them as you like by changing font name, color, size and use offset to place them above each other.

As you can see in the example below, I put the Japanese labels and English Labels into two fields and then controlled the appearance of each label as I wanted to be:

enter image description here

To do this:

  • Go to Layer properties -> Labels
  • Select Rule-Based Labeling

enter image description here

  • Define the fields that you want to use in the labeling, each one separately. In this example, I used Name_JP and Name_EN.
  • Use the style for each one independently and customize each one as you like.
  • The most important is to use Offset under Placement for the one of the labels so that they can be above each other. For the first label field I used the following placement settings:

enter image description here

For the second label field I used the following settings:

enter image description here

Tested on QGIS 3.0.1, But it can also applied in QGIS 2.18 because Rule-Based Labeling option is available.

Answered by ahmadhanb on September 3, 2021

I used a duplicate of the same layer and labelled both with placements above and under respectively after checking 'show all labels and features for all layers'as attached and it works!

Answered by Asiku Emmanuel on September 3, 2021

This should be achieved using fonts symbols markers with the label background settings.

Unfortunately, there is a bug in the Characters Expressions… The fields datas are not rendered. The bug report explains in details how to proceed. https://github.com/qgis/QGIS/issues/36944

Answered by M-Rick on September 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP