[GIS] Set the label size to fit the scale in the composer window

labelingqgis

Is there a way to set the labels size of font to fit the scale of the map in the composer window but also to fit in the main window?

The map in the composer is size A0 and the scale is 1:5000.
In order to see the labels clearly in the composer, I set the labels font size to 23. So in the main window it's too large but in the composer it's OK.

Best Answer

In the labels properties choose a data defined properties for the size (drop-down menu on the right of the field) and plug-in this expression.

CASE
WHEN  $map='mymapincomposer' THEN 23
WHEN  $map='canvas' THEN 8
ELSE 12
END

You'll just have to replace 'mymapincomposer' by the name of the map item in your composition. Just adapt the expression if you have multiple composers. please note the id name for the main windows is 'canvas'.

Enjoy!