47 const QVector< double > &characterWidths,
48 const QVector< double > &characterHeights,
49 const QVector< double > &characterDescents )
51 , mCharacterHeights( characterHeights )
52 , mCharacterWidths( characterWidths )
53 , mCharacterDescents( characterDescents )
55 Q_ASSERT( mCharacterHeights.size() == mCharacterWidths.size() );
56 Q_ASSERT( mCharacterDescents.size() == mCharacterWidths.size() );
58 if ( !mCharacterHeights.empty() )
60 mMaximumCharacterHeight = *std::max_element( mCharacterHeights.constBegin(), mCharacterHeights.constEnd() );
61 mMaximumCharacterDescent = *std::max_element( mCharacterDescents.constBegin(), mCharacterDescents.constEnd() );
68 int count()
const {
return static_cast< int >( mCharacterWidths.size() ); }
77 return mCharacterWidths[position];
89 return mCharacterHeights[position];
101 return mCharacterDescents[position];
126 QString
grapheme(
int index )
const {
return mGraphemes.at( index ); }
131 void setGraphemeFormats(
const QVector< QgsTextCharacterFormat > &formats ) { mGraphemeFormats = formats; }
145 QStringList mGraphemes;
146 QVector< QgsTextCharacterFormat > mGraphemeFormats;
147 QVector< double > mCharacterHeights;
148 QVector< double > mCharacterWidths;
149 QVector< double > mCharacterDescents;
150 double mMaximumCharacterHeight = 0;
151 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().