20#include <QTextCharFormat>
23 : mTextColor( format.hasProperty( QTextFormat::ForegroundBrush ) ? format.foreground().color() : QColor() )
24 , mFontWeight( format.hasProperty( QTextFormat::FontWeight ) ? format.fontWeight() : -1 )
25 , mStyleName( format.font().styleName() )
27 , mFontPointSize( format.hasProperty( QTextFormat::FontPointSize ) ? format.fontPointSize() : - 1 )
28 , mFontFamily( format.hasProperty( QTextFormat::FontFamily ) ? format.fontFamily() : QString() )
48 return mFontPointSize;
53 mFontPointSize = size;
68 return mStrikethrough;
73 mStrikethrough = strikethrough;
99 if ( !mFontFamily.isEmpty() )
100 font.setFamily( mFontFamily );
102 if ( mFontPointSize != -1 )
108 if ( mFontWeight != - 1 )
110#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
111 font.setWeight( mFontWeight );
113 if ( mFontWeight <= 150 )
114 font.setWeight( QFont::Thin );
115 else if ( mFontWeight <= 250 )
116 font.setWeight( QFont::ExtraLight );
117 else if ( mFontWeight <= 350 )
118 font.setWeight( QFont::Light );
119 else if ( mFontWeight <= 450 )
120 font.setWeight( QFont::Normal );
121 else if ( mFontWeight <= 550 )
122 font.setWeight( QFont::Medium );
123 else if ( mFontWeight <= 650 )
124 font.setWeight( QFont::DemiBold );
125 else if ( mFontWeight <= 750 )
126 font.setWeight( QFont::Bold );
127 else if ( mFontWeight <= 850 )
128 font.setWeight( QFont::ExtraBold );
130 font.setWeight( QFont::Black );
135 font.setStyleName( mStyleName );
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
void setFamily(const QString &family)
Sets the font family name.
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 ...
void setFontWeight(int fontWeight)
Sets the font weight.
QColor textColor() const
Returns the character's text color, or an invalid color if no color override is set and the default f...
BooleanValue italic() const
Returns whether the format has italic enabled.
QgsTextCharacterFormat()=default
Constructor for QgsTextCharacterFormat.
void setStrikeOut(BooleanValue enabled)
Sets whether the format has strikethrough enabled.
void setOverline(BooleanValue enabled)
Sets whether the format has overline enabled.
BooleanValue
Status values for boolean format properties.
@ SetTrue
Property is set and true.
@ NotSet
Property is not set.
int fontWeight() const
Returns the font weight, or -1 if the font weight is not set and should be inherited.
BooleanValue strikeOut() const
Returns whether the format has strikethrough enabled.
double fontPointSize() const
Returns the font point size, or -1 if the font size is not set and should be inherited.
QString family() const
Returns the font family name, or an empty string if the family is not set and should be inherited.
BooleanValue underline() const
Returns whether the format has underline enabled.
void setTextColor(const QColor &textColor)
Sets the character's text color.
void setUnderline(BooleanValue enabled)
Sets whether the format has underline enabled.
void setItalic(BooleanValue enabled)
Sets whether the format has italic enabled.
BooleanValue overline() const
Returns whether the format has overline enabled.
void setFontPointSize(double size)
Sets the font point size.
@ RenderPoints
Points (e.g., for font sizes)