20#include <QTextCharFormat>
24 set = format.hasProperty( QTextFormat::TextVerticalAlignment );
25 switch ( format.verticalAlignment() )
27 case QTextCharFormat::AlignNormal:
29 case QTextCharFormat::AlignSuperScript:
31 case QTextCharFormat::AlignSubScript:
35 case QTextCharFormat::AlignMiddle:
36 case QTextCharFormat::AlignTop:
37 case QTextCharFormat::AlignBottom:
38 case QTextCharFormat::AlignBaseline:
46 : mTextColor( format.hasProperty( QTextFormat::ForegroundBrush ) ? format.foreground().color() : QColor() )
47 , mFontWeight( format.hasProperty( QTextFormat::FontWeight ) ? format.fontWeight() : -1 )
48 , mStyleName( format.font().styleName() )
50 , mFontPointSize( format.hasProperty( QTextFormat::FontPointSize ) ? format.fontPointSize() : - 1 )
51 , mFontFamily( format.hasProperty( QTextFormat::FontFamily ) ? format.fontFamily() : QString() )
71 return mFontPointSize;
76 mFontPointSize = size;
91 return mStrikethrough;
96 mStrikethrough = strikethrough;
122 if ( !mFontFamily.isEmpty() )
125 if ( mFontPointSize != -1 )
131 if ( mFontWeight != - 1 )
133#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
134 font.setWeight( mFontWeight );
136 if ( mFontWeight <= 150 )
137 font.setWeight( QFont::Thin );
138 else if ( mFontWeight <= 250 )
139 font.setWeight( QFont::ExtraLight );
140 else if ( mFontWeight <= 350 )
141 font.setWeight( QFont::Light );
142 else if ( mFontWeight <= 450 )
143 font.setWeight( QFont::Normal );
144 else if ( mFontWeight <= 550 )
145 font.setWeight( QFont::Medium );
146 else if ( mFontWeight <= 650 )
147 font.setWeight( QFont::DemiBold );
148 else if ( mFontWeight <= 750 )
149 font.setWeight( QFont::Bold );
150 else if ( mFontWeight <= 850 )
151 font.setWeight( QFont::ExtraBold );
153 font.setWeight( QFont::Black );
158 font.setStyleName( mStyleName );
TextCharacterVerticalAlignment
Text vertical alignment for characters.
@ Normal
Adjacent characters are positioned in the standard way for text in the writing system in use.
@ SubScript
Characters are placed below the base line for normal text.
@ SuperScript
Characters are placed above the base line for normal text.
@ Points
Points (e.g., for font sizes)
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, Qgis::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.
#define BUILTIN_UNREACHABLE
Qgis::TextCharacterVerticalAlignment convertTextCharFormatVAlign(const QTextCharFormat &format, bool &set)