In Relating text buffer to text size in QGIS? I displayed various polygon sizes : the objective of my research was to try to adjust automatically the buffer size of the text to the font size because the buffer tended to be too large for little texts.
I'm now looking for a way to adapt the font size to the polygon area. This way, i won't have to put it into the attribute table and fix manually the font size i need.
Best Answer
EDIT June 2018: easier solution in QGIS 2.18+ !
It's possible to do it directly, without a virtual field as in my previous answer :
ln($area)
(or log(base, $area) as suggested by @Stephen Kay in comments, with base an integer you choose)ln($area)/15
in the data defined properties of the size.EDIT June 2018: I leave my previous solution below for info
An easy way to do this is by using the ln() function (for example).
ln($area)
This basic formula answers my needs but you can of course tweak it to suits yours by adding/multiplying values (or else).
Tip : you can combine this with the following tip : do a virtual field VRT_BUFF with the formula
"VRT_FONT"/15
and set the lable font buffer to this field to have an area adaptive buffer too. Tip 2 : you can modify the formula to fit your own scale needs and the size of buffer you would like.What it does :
The field properties :
The attribute table :
A new polygon :