Well positioned and styled labels shouldn’t need halos, but this isn’t always possible. When you have a lot of labels to add and you’re putting them over raster data you can’t use automatic detection of features between layers. Manually moving each label can be out of the question if you have thousands, so what do you do? The answer is add to add a halo, allowing the text to become legible even if it is overlying something the same colour.
However, adding a pure black or white halo to your text isn’t always a good look, even if it does make the text legible. Also in many cases might not even be needed as there is enough contrast with the background.
Using QGIS Blend Modes on Halos
So what can you do in these situations? Help is at hand in QGIS as you can use blend modes to add halos to your text that only appear where they are needed!
Blend modes for label halos have existed for some time and can be used in a couple of ways to make your halos disappear where they are not required. The two blend modes of the most use are Multiply and Screen depending on whether you are using light or dark text.
To add a halo and then apply a blend mode you need to be in the label section of the Layer Styling panel :
- Click on the “ABC” Label section
- Select the Halo tab
- Choose the appropriate blend mode at the bottom:
- For dark or black text, use the Screen blend mode to brighten the darker areas preventing your text standing out.
- For light or white text, use the Multiply blend mode to darken the brighter areas preventing your text standing out.
Blending Coloured Halos
When you are placing text over an area with are a reasonably consistent colour such as a green forest or dusty brown desert you can use this to your advantage. You can choose a halo colour that blends with this colour, the dropper is helpful for this, which you can then darken or lighten in the colour swatch panel depending on your text colour. Nyall Dawson explained this process very well here:
Blending Halos for Cityscapes or other Multicoloured Areas
If you are looking to use this effect for hundreds or thousands of labels across a city then you are not going to be able to find a single colour that works for a halo.
I have found that if you use a grey rather than a colour it is always effective for blending . Use either a dark grey for lightening, or a light grey for Darkening with. Now the Halo really only shows up when there is the least contrast with your label.
I have found that 66% grey for dark text and 33% for light text works really well to help blend in the Halo. This also ensures it really only appears over areas that don’t have enough contrast with the text:
Using QGIS Draw Effects on Halos
One final issue that you need to combat was highlighted in Nyall’s post. Where there are extreme changes in contrast behind your text then the halo’s effectiveness can be greatly reduced. This is where the use of a blur can really help, softening the contrast and boosting the effectiveness of your halos. Nyall’s post mentioned that the Blur effect was coming to QGIS soon and now it’s ready to use. Now there is no need to use another program to add the blur.
To add the blur effect you need to turn on Draw Effects:
- Tick the Draw effects check box just below where you added the blend mode.
- Click on the yellow star.
Once the Effects Properties panel is open:
- Change the Effect type to be a Blur
- Set the Blur Type to be Gaussian blur (quality)
- Change the Blur strength to be 10:
The end result should be that your halos only become noticeable when there isn’t enough contrast with the text; much less intrusive yet the text remains legible:
These techniques are all reasonably well established in cartography but with QGIS 3 you no longer need any other software to blend or blur the halo.