Class: QgsPalLabeling¶
PAL labeling utilities.
Static Methods
Checks whether a geometry requires preparation before registration with PAL  | 
|
Prepares a geometry for registration with PAL.  | 
|
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string.  | 
|
Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter).  | 
|
Called to find out whether a specified layer is used for labeling.  | 
- class qgis.core.QgsPalLabeling[source]¶
 Bases:
object- static geometryRequiresPreparation(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry(), mergeLines: bool = False) bool[source]¶
 Checks whether a geometry requires preparation before registration with PAL
- Parameters:
 geometry (QgsGeometry) – geometry to prepare
context (QgsRenderContext) – render context
ct (QgsCoordinateTransform) – coordinate transform, or invalid transform if no transformation required
clipGeometry (
QgsGeometry= QgsGeometry()) – geometry to clip features to, if applicablemergeLines (bool = False) –
Trueif touching lines from this layer will be merged and treated as single features during labeling
- Return type:
 bool
- Returns:
 Trueif geometry requires preparation
- static prepareGeometry(geometry: QgsGeometry, context: QgsRenderContext, ct: QgsCoordinateTransform, clipGeometry: QgsGeometry = QgsGeometry(), mergeLines: bool = False) QgsGeometry[source]¶
 Prepares a geometry for registration with PAL. Handles reprojection, rotation, clipping, etc.
- Parameters:
 geometry (QgsGeometry) – geometry to prepare
context (QgsRenderContext) – render context
ct (QgsCoordinateTransform) – coordinate transform, or invalid transform if no transformation required
clipGeometry (
QgsGeometry= QgsGeometry()) – geometry to clip features to, if applicablemergeLines (bool = False) –
Trueif touching lines from this layer will be merged and treated as single features during labeling
- Return type:
 - Returns:
 prepared geometry
- static splitToGraphemes(text: str | None) List[str][source]¶
 Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string. This accounts for scripts were individual characters are not allowed to be split apart (e.g., Arabic and Indic based scripts)
- Parameters:
 text (Optional[str]) – string to split
- Return type:
 List[str]
- Returns:
 list of graphemes
- static splitToLines(text: str | None, wrapCharacter: str | None, autoWrapLength: int = 0, useMaxLineLengthWhenAutoWrapping: bool = True) List[str][source]¶
 Splits a
textstring to a list of separate lines, using a specified wrap character (wrapCharacter). The text string will be split on either newline characters or the wrap character.Since QGIS 3.4 the
autoWrapLengthargument can be used to specify an ideal length of line to automatically wrap text to (automatic wrapping is disabled ifautoWrapLengthis 0). This automatic wrapping is performed after processing wrapping usingwrapCharacter. When auto wrapping is enabled, theuseMaxLineLengthWhenAutoWrappingargument controls whether the lines should be wrapped to an ideal maximum ofautoWrapLengthcharacters, or ifFalsethen the lines are wrapped to an ideal minimum length ofautoWrapLengthcharacters.- Parameters:
 text (Optional[str])
wrapCharacter (Optional[str])
autoWrapLength (int = 0)
useMaxLineLengthWhenAutoWrapping (bool = True)
- Return type:
 List[str]
- static staticWillUseLayer(layer: QgsMapLayer | None) bool[source]¶
 Called to find out whether a specified
layeris used for labeling.- Parameters:
 layer (Optional[QgsMapLayer])
- Return type:
 bool