QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
Classes | Public Types | Static Public Member Functions | List of all members
QgsTextRendererUtils Class Reference

Utility functions for text rendering. More...

#include <qgstextrendererutils.h>

Classes

class  CurvedGraphemePlacement
 Contains placement information for a single grapheme in a curved text layout. More...
 
class  CurvePlacementProperties
 Contains placement information for a curved text layout. More...
 

Public Types

enum  LabelLineDirection { RespectPainterOrientation , FollowLineDirection }
 Controls behavior of curved text with respect to line directions. More...
 

Static Public Member Functions

static QgsUnitTypes::RenderUnit convertFromOldLabelUnit (int val)
 Converts a unit from an old (pre 3.0) label unit. More...
 
static QgsTextBackgroundSettings::RotationType decodeBackgroundRotationType (const QString &string)
 Decodes a string representation of a background rotation type to a type. More...
 
static QgsTextBackgroundSettings::SizeType decodeBackgroundSizeType (const QString &string)
 Decodes a string representation of a background size type to a type. More...
 
static QgsTextShadowSettings::ShadowPlacement decodeShadowPlacementType (const QString &string)
 Decodes a string representation of a shadow placement type to a type. More...
 
static QgsTextBackgroundSettings::ShapeType decodeShapeType (const QString &string)
 Decodes a string representation of a background shape type to a type. More...
 
static QgsTextFormat::TextOrientation decodeTextOrientation (const QString &name, bool *ok=nullptr)
 Attempts to decode a string representation of a text orientation. More...
 
static QString encodeTextOrientation (QgsTextFormat::TextOrientation orientation)
 Encodes a text orientation. More...
 
static CurvePlacementPropertiesgenerateCurvedTextPlacement (const QgsPrecalculatedTextMetrics &metrics, const double *x, const double *y, int numPoints, const std::vector< double > &pathDistances, double offsetAlongLine, LabelLineDirection direction=RespectPainterOrientation, double maxConcaveAngle=-1, double maxConvexAngle=-1, bool uprightOnly=true)
 Calculates curved text placement properties. More...
 
static QColor readColor (QgsVectorLayer *layer, const QString &property, const QColor &defaultColor=Qt::black, bool withAlpha=true)
 Converts an encoded color value from a layer property. More...
 

Detailed Description

Utility functions for text rendering.

Since
QGIS 3.10

Definition at line 32 of file qgstextrendererutils.h.

Member Enumeration Documentation

◆ LabelLineDirection

Controls behavior of curved text with respect to line directions.

Enumerator
RespectPainterOrientation 

Curved text will be placed respecting the painter orientation, and the actual line direction will be ignored.

FollowLineDirection 

Curved text placement will respect the line direction and ignore painter orientation.

Definition at line 139 of file qgstextrendererutils.h.

Member Function Documentation

◆ convertFromOldLabelUnit()

QgsUnitTypes::RenderUnit QgsTextRendererUtils::convertFromOldLabelUnit ( int  val)
static

Converts a unit from an old (pre 3.0) label unit.

Note
Not available in Python bindings.
Since
QGIS 3.14

Definition at line 132 of file qgstextrendererutils.cpp.

◆ decodeBackgroundRotationType()

QgsTextBackgroundSettings::RotationType QgsTextRendererUtils::decodeBackgroundRotationType ( const QString &  string)
static

Decodes a string representation of a background rotation type to a type.

Definition at line 61 of file qgstextrendererutils.cpp.

◆ decodeBackgroundSizeType()

QgsTextBackgroundSettings::SizeType QgsTextRendererUtils::decodeBackgroundSizeType ( const QString &  string)
static

Decodes a string representation of a background size type to a type.

Definition at line 48 of file qgstextrendererutils.cpp.

◆ decodeShadowPlacementType()

QgsTextShadowSettings::ShadowPlacement QgsTextRendererUtils::decodeShadowPlacementType ( const QString &  string)
static

Decodes a string representation of a shadow placement type to a type.

Definition at line 78 of file qgstextrendererutils.cpp.

◆ decodeShapeType()

QgsTextBackgroundSettings::ShapeType QgsTextRendererUtils::decodeShapeType ( const QString &  string)
static

Decodes a string representation of a background shape type to a type.

Definition at line 20 of file qgstextrendererutils.cpp.

◆ decodeTextOrientation()

QgsTextFormat::TextOrientation QgsTextRendererUtils::decodeTextOrientation ( const QString &  name,
bool *  ok = nullptr 
)
static

Attempts to decode a string representation of a text orientation.

Parameters
nameencoded text orientation name
okif specified, will be set to true if the name was successfully decoded
Returns
decoded text orientation
See also
encodeTextOrientation()

Definition at line 113 of file qgstextrendererutils.cpp.

◆ encodeTextOrientation()

QString QgsTextRendererUtils::encodeTextOrientation ( QgsTextFormat::TextOrientation  orientation)
static

Encodes a text orientation.

Returns
encoded string
See also
decodeTextOrientation()

Definition at line 99 of file qgstextrendererutils.cpp.

◆ generateCurvedTextPlacement()

QgsTextRendererUtils::CurvePlacementProperties * QgsTextRendererUtils::generateCurvedTextPlacement ( const QgsPrecalculatedTextMetrics metrics,
const double *  x,
const double *  y,
int  numPoints,
const std::vector< double > &  pathDistances,
double  offsetAlongLine,
LabelLineDirection  direction = RespectPainterOrientation,
double  maxConcaveAngle = -1,
double  maxConvexAngle = -1,
bool  uprightOnly = true 
)
static

Calculates curved text placement properties.

Parameters
metricsprecalculated text metrics for text to render
xarray of linestring x coordinates
yarray of linestring y coordinates
numPointsnumber of points in x, y arrays
pathDistancesvector of precalculated distances between vertices in x, y arrays
offsetAlongLineoffset along line at which to start the curved text placement
directioncontrols placement of text with respect to painter orientation or line direction
maxConcaveAnglemaximum angle between characters for concave text, or -1 if not set
maxConvexAnglemaximum angle between characters for convex text, or -1 if not set
uprightOnlyset to true if text should be placed in an upright orientation only, or false to allow upside down text placement
Returns
calculated placement properties, or nullptr if placement could not be calculated. Caller takes ownership of the returned placement.
Since
QGIS 3.20

Definition at line 183 of file qgstextrendererutils.cpp.

◆ readColor()

QColor QgsTextRendererUtils::readColor ( QgsVectorLayer layer,
const QString &  property,
const QColor &  defaultColor = Qt::black,
bool  withAlpha = true 
)
static

Converts an encoded color value from a layer property.

Note
Not available in Python bindings.
Since
QGIS 3.14

Definition at line 146 of file qgstextrendererutils.cpp.


The documentation for this class was generated from the following files: