17 #include <QFontMetricsF>
18 #include <QTextFragment>
22 , mCharFormat( format )
26 : mText( fragment.text() )
44 mCharFormat = charFormat;
49 if ( fontHasBeenUpdatedForFragment )
51 QFontMetricsF fm( font );
52 return fm.horizontalAdvance( mText );
56 QFont updatedFont = font;
58 QFontMetricsF fm( updatedFont );
59 return fm.horizontalAdvance( mText );
static QString capitalize(const QString &string, Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
Capitalization
Capitalization options.
Stores information relating to individual character formatting.
void updateFontForFormat(QFont &font, double scaleFactor=1.0) const
Updates the specified font in place, applying character formatting options which are applicable on a ...
void setText(const QString &text)
Sets the text content of the fragment.
QString text() const
Returns the text content of the fragment.
void setCharacterFormat(const QgsTextCharacterFormat &format)
Sets the character format for the fragment.
double horizontalAdvance(const QFont &font, bool fontHasBeenUpdatedForFragment=false, double scaleFactor=1.0) const
Returns the horizontal advance associated with this fragment, when rendered using the specified base ...
void applyCapitalization(QgsStringUtils::Capitalization capitalization)
Applies a capitalization style to the fragment's text.
QgsTextFragment(const QString &text=QString(), const QgsTextCharacterFormat &format=QgsTextCharacterFormat())
Constructor for QgsTextFragment, with the specified text and optional character format.