settings = QgsPalLayerSettings() settings.fieldName = 'name' settings.isExpression = False settings.enabled = True settings.placement = 0 settings.setDataDefinedProperty(QgsPalLayerSettings.Size, True, '8')
settings = QgsPalLayerSettings() settings.fieldName = 'name' settings.isExpression = False settings.enabled = True settings.placement = 0 settings.setDataDefinedProperty(QgsPalLayerSettings.Size, True, '8') settings.setDataDefinedProperty(QgsPalLayerSettings.FontFamily, True, 'Arial') settings.setDataDefinedProperty(QgsPalLayerSettings.FontStyle, True, 'Bold') settings.setDataDefinedProperty(QgsPalLayerSettings.Color, True, '#ff0000')This example sets the same basic settings as Example 1 but also sets the font to Arial, makes it bold, and sets the text color to red. Package library: Python QGIS Core.