Skip to main content
2 of 4
added 265 characters in body
underdark
  • 84.5k
  • 22
  • 233
  • 415

Works for me:

valLabel=QgsPalLayerSettings()
valLabel.readFromLayer(iface.activeLayer())
valLabel.fontSizeInMapUnits=True
valLabel.writeToLayer(iface.activeLayer())
iface.mapCanvas().refresh()

For the data-defined way check QgsPalLayerSettings::DataDefinedProperties FontSizeUnit

and enum QgsPalLayerSettings::SizeUnit

Units used for option sizes, before being converted to rendered sizes.

Enumerator

Points
MM
MapUnits
Percent

underdark
  • 84.5k
  • 22
  • 233
  • 415