45 QgsPrecalculatedTextMetrics(
const QStringList &
graphemes,
const QVector< double > &characterWidths,
const QVector< double > &characterHeights,
const QVector< double > &characterDescents )
47 , mCharacterHeights( characterHeights )
48 , mCharacterWidths( characterWidths )
49 , mCharacterDescents( characterDescents )
51 Q_ASSERT( mCharacterHeights.size() == mCharacterWidths.size() );
52 Q_ASSERT( mCharacterDescents.size() == mCharacterWidths.size() );
54 if ( !mCharacterHeights.empty() )
56 mMaximumCharacterHeight = *std::max_element( mCharacterHeights.constBegin(), mCharacterHeights.constEnd() );
57 mMaximumCharacterDescent = *std::max_element( mCharacterDescents.constBegin(), mCharacterDescents.constEnd() );
64 int count()
const {
return static_cast< int >( mCharacterWidths.size() ); }
73 return mCharacterWidths[position];
85 return mCharacterHeights[position];
97 return mCharacterDescents[position];
122 QString
grapheme(
int index )
const {
return mGraphemes.at( index ); }
127 void setGraphemeFormats(
const QVector< QgsTextCharacterFormat > &formats ) { mGraphemeFormats = formats; }
140 QStringList mGraphemes;
141 QVector< QgsTextCharacterFormat > mGraphemeFormats;
142 QVector< double > mCharacterHeights;
143 QVector< double > mCharacterWidths;
144 QVector< double > mCharacterDescents;
145 double mMaximumCharacterHeight = 0;
146 double mMaximumCharacterDescent = 0;
int graphemeFormatCount() const
Returns the number of grapheme formats available.
QgsTextCharacterFormat graphemeFormat(int index) const
Returns the character format for the grapheme at the specified index.
double maximumCharacterHeight() const
Returns the maximum height of any character found in the text.
QStringList graphemes() const
Returns the list of graphemes contained in the text.
QgsPrecalculatedTextMetrics(const QStringList &graphemes, const QVector< double > &characterWidths, const QVector< double > &characterHeights, const QVector< double > &characterDescents)
Constructor for QgsPrecalculatedTextMetrics.
double characterDescent(int position) const
Returns the descent of the character at the specified position.
int count() const
Returns the total number of characters.
double maximumCharacterDescent() const
Returns the maximum descent of any character found in the text.
double characterWidth(int position) const
Returns the width of the character at the specified position.
QString grapheme(int index) const
Returns the grapheme at the specified index.
double characterHeight(int position) const
Returns the character height of the character at the specified position (actually font metrics height...
void setGraphemeFormats(const QVector< QgsTextCharacterFormat > &formats)
Sets the character formats associated with the text graphemes().