QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Types | Public Member Functions | List of all members
QgsTextCharacterFormat Class Reference

Stores information relating to individual character formatting. More...

#include <qgstextcharacterformat.h>

Public Types

enum class  BooleanValue { NotSet , SetTrue , SetFalse }
 Status values for boolean format properties. More...
 

Public Member Functions

 QgsTextCharacterFormat ()=default
 Constructor for QgsTextCharacterFormat. More...
 
 QgsTextCharacterFormat (const QTextCharFormat &format)
 Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat format. More...
 
QString family () const
 Returns the font family name, or an empty string if the family is not set and should be inherited. More...
 
double fontPointSize () const
 Returns the font point size, or -1 if the font size is not set and should be inherited. More...
 
int fontWeight () const
 Returns the font weight, or -1 if the font weight is not set and should be inherited. More...
 
BooleanValue italic () const
 Returns whether the format has italic enabled. More...
 
BooleanValue overline () const
 Returns whether the format has overline enabled. More...
 
void setFamily (const QString &family)
 Sets the font family name. More...
 
void setFontPointSize (double size)
 Sets the font point size. More...
 
void setFontWeight (int fontWeight)
 Sets the font weight. More...
 
void setItalic (BooleanValue enabled)
 Sets whether the format has italic enabled. More...
 
void setOverline (BooleanValue enabled)
 Sets whether the format has overline enabled. More...
 
void setStrikeOut (BooleanValue enabled)
 Sets whether the format has strikethrough enabled. More...
 
void setTextColor (const QColor &textColor)
 Sets the character's text color. More...
 
void setUnderline (BooleanValue enabled)
 Sets whether the format has underline enabled. More...
 
BooleanValue strikeOut () const
 Returns whether the format has strikethrough enabled. More...
 
QColor textColor () const
 Returns the character's text color, or an invalid color if no color override is set and the default format color should be used. More...
 
BooleanValue underline () const
 Returns whether the format has underline enabled. More...
 
void updateFontForFormat (QFont &font, const QgsRenderContext &context, double scaleFactor=1.0) const
 Updates the specified font in place, applying character formatting options which are applicable on a font level when rendered in the given context. More...
 

Detailed Description

Stores information relating to individual character formatting.

These options encapsulate formatting options which override the default settings from a QgsTextFormat for individual characters (or sets of characters).

Warning
This API is not considered stable and may change in future QGIS versions.
Since
QGIS 3.14

Definition at line 40 of file qgstextcharacterformat.h.

Member Enumeration Documentation

◆ BooleanValue

Status values for boolean format properties.

Enumerator
NotSet 

Property is not set.

SetTrue 

Property is set and true.

SetFalse 

Property is set and false.

Definition at line 55 of file qgstextcharacterformat.h.

Constructor & Destructor Documentation

◆ QgsTextCharacterFormat() [1/2]

QgsTextCharacterFormat::QgsTextCharacterFormat ( )
default

Constructor for QgsTextCharacterFormat.

◆ QgsTextCharacterFormat() [2/2]

QgsTextCharacterFormat::QgsTextCharacterFormat ( const QTextCharFormat &  format)

Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat format.

Definition at line 22 of file qgstextcharacterformat.cpp.

Member Function Documentation

◆ family()

QString QgsTextCharacterFormat::family ( ) const

Returns the font family name, or an empty string if the family is not set and should be inherited.

See also
setFamily()
Since
QGIS 3.28

Definition at line 56 of file qgstextcharacterformat.cpp.

◆ fontPointSize()

double QgsTextCharacterFormat::fontPointSize ( ) const

Returns the font point size, or -1 if the font size is not set and should be inherited.

See also
setFontPointSize()
Since
QGIS 3.28

Definition at line 46 of file qgstextcharacterformat.cpp.

◆ fontWeight()

int QgsTextCharacterFormat::fontWeight ( ) const

Returns the font weight, or -1 if the font weight is not set and should be inherited.

See also
setFontWeight()
Since
QGIS 3.28

Definition at line 156 of file qgstextcharacterformat.cpp.

◆ italic()

QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::italic ( ) const

Returns whether the format has italic enabled.

See also
setItalic()
Since
QGIS 3.28

Definition at line 146 of file qgstextcharacterformat.cpp.

◆ overline()

QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::overline ( ) const

Returns whether the format has overline enabled.

See also
setUnderline()

Definition at line 86 of file qgstextcharacterformat.cpp.

◆ setFamily()

void QgsTextCharacterFormat::setFamily ( const QString &  family)

Sets the font family name.

Set to an empty string if the family should be inherited.

See also
family()
Since
QGIS 3.28

Definition at line 61 of file qgstextcharacterformat.cpp.

◆ setFontPointSize()

void QgsTextCharacterFormat::setFontPointSize ( double  size)

Sets the font point size.

Set size to -1 if the font size is not set and should be inherited.

See also
fontPointSize()
Since
QGIS 3.28

Definition at line 51 of file qgstextcharacterformat.cpp.

◆ setFontWeight()

void QgsTextCharacterFormat::setFontWeight ( int  fontWeight)

Sets the font weight.

Set weight to -1 if the font weight is not set and should be inherited.

See also
fontWeight()
Since
QGIS 3.28

Definition at line 161 of file qgstextcharacterformat.cpp.

◆ setItalic()

void QgsTextCharacterFormat::setItalic ( QgsTextCharacterFormat::BooleanValue  enabled)

Sets whether the format has italic enabled.

See also
italic()
Since
QGIS 3.28

Definition at line 151 of file qgstextcharacterformat.cpp.

◆ setOverline()

void QgsTextCharacterFormat::setOverline ( QgsTextCharacterFormat::BooleanValue  enabled)

Sets whether the format has overline enabled.

See also
overline()

Definition at line 91 of file qgstextcharacterformat.cpp.

◆ setStrikeOut()

void QgsTextCharacterFormat::setStrikeOut ( BooleanValue  enabled)

Sets whether the format has strikethrough enabled.

See also
strikeOut()

Definition at line 71 of file qgstextcharacterformat.cpp.

◆ setTextColor()

void QgsTextCharacterFormat::setTextColor ( const QColor &  textColor)

Sets the character's text color.

Set color to an invalid color if no color override is desired and the default format color should be used.

See also
textColor()

Definition at line 41 of file qgstextcharacterformat.cpp.

◆ setUnderline()

void QgsTextCharacterFormat::setUnderline ( BooleanValue  enabled)

Sets whether the format has underline enabled.

See also
underline()

Definition at line 81 of file qgstextcharacterformat.cpp.

◆ strikeOut()

QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::strikeOut ( ) const

Returns whether the format has strikethrough enabled.

See also
setStrikeOut()

Definition at line 66 of file qgstextcharacterformat.cpp.

◆ textColor()

QColor QgsTextCharacterFormat::textColor ( ) const

Returns the character's text color, or an invalid color if no color override is set and the default format color should be used.

See also
setTextColor()

Definition at line 36 of file qgstextcharacterformat.cpp.

◆ underline()

QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::underline ( ) const

Returns whether the format has underline enabled.

See also
setUnderline()

Definition at line 76 of file qgstextcharacterformat.cpp.

◆ updateFontForFormat()

void QgsTextCharacterFormat::updateFontForFormat ( QFont &  font,
const QgsRenderContext context,
double  scaleFactor = 1.0 
) const

Updates the specified font in place, applying character formatting options which are applicable on a font level when rendered in the given context.

The optional scaleFactor parameter can specify a font size scaling factor. It is recommended to set this to QgsTextRenderer::FONT_WORKAROUND_SCALE and then manually calculations based on the resultant font metrics. Failure to do so will result in poor quality text rendering at small font sizes.

Definition at line 96 of file qgstextcharacterformat.cpp.


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