46 const QVector< double > &characterWidths,
47 const QVector< double > &characterHeights,
48 const QVector< double > &characterDescents )
49 : mGraphemes( graphemes )
50 , mCharacterHeights( characterHeights )
51 , mCharacterWidths( characterWidths )
52 , mCharacterDescents( characterDescents )
54 Q_ASSERT( mCharacterHeights.size() == mCharacterWidths.size() );
55 Q_ASSERT( mCharacterDescents.size() == mCharacterWidths.size() );
57 if ( !mCharacterHeights.empty() )
59 mMaximumCharacterHeight = *std::max_element( mCharacterHeights.constBegin(), mCharacterHeights.constEnd() );
60 mMaximumCharacterDescent = *std::max_element( mCharacterDescents.constBegin(), mCharacterDescents.constEnd() );
67 int count()
const {
return static_cast< int >( mCharacterWidths.size() ); }
72 double characterWidth(
int position )
const {
return mCharacterWidths[position]; }
79 double characterHeight(
int position )
const {
return mCharacterHeights[position]; }
110 QString
grapheme(
int index )
const {
return mGraphemes.at( index ); }
115 void setGraphemeFormats(
const QVector< QgsTextCharacterFormat > &formats ) { mGraphemeFormats = formats; }
129 QStringList mGraphemes;
130 QVector< QgsTextCharacterFormat > mGraphemeFormats;
131 QVector< double > mCharacterHeights;
132 QVector< double > mCharacterWidths;
133 QVector< double > mCharacterDescents;
134 double mMaximumCharacterHeight = 0;
135 double mMaximumCharacterDescent = 0;
Contains precalculated properties regarding text metrics for text to be renderered at a later stage.
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().