58 bool isValid()
const {
return mAtlasSize.isValid(); }
70 QRect rect(
const QString &grapheme )
const;
78 QRect rect(
const QString &grapheme )
const;
80 const QRect res = sipCpp->rect( *a0 );
83 PyErr_SetString( PyExc_KeyError, u
"No rectangle for character %1 exists."_s.arg( *a0 ).toUtf8().constData() );
88 return sipConvertFromNewType(
new QRect( res ), sipType_QRect, Py_None );
99 int graphemeCount(
const QString &
string )
const;
107 int totalWidth(
const QString &
string )
const;
115 QPoint pixelOffsetForGrapheme(
const QString &
string,
int graphemeIndex )
const;
123 QRect textureRectForGrapheme(
const QString &
string,
int graphemeIndex )
const;
128 QImage renderAtlasTexture()
const;
136 QImage renderDebugTexture()
const;
146 Returns the number of textures in the atlas.
155 struct GraphemeMetric
157 GraphemeMetric(
int horizontalAdvance = 0,
const QString &grapheme = QString() )
158 : horizontalAdvance( horizontalAdvance )
159 , grapheme( grapheme )
162 int horizontalAdvance = 0;
169 QVector< GraphemeMetric > graphemeMetrics;
172 QgsTextFormat mFormat;
173 std::vector< QgsCharTextureRect > mRects;
175 QHash< QString, int > mGraphemeIndices;
176 QMap< QString, StringMetrics > mStringMetrics;
177 int mTexturePaddingPixels = 0;
Generates texture atlases for a font by efficiently packing the characters required for a set of stri...
static QgsFontTextureAtlas create(const QgsTextFormat &format, const QStringList &strings)
Creates the texture atlas for a set of strings, using the specified text format.
Encapsulates a font texture atlas.
QSize atlasSize() const
Returns the total size required for the atlas, i.e.
friend class QgsFontTextureAtlasGenerator
bool isValid() const
Returns true if the atlas is valid.
QgsFontTextureAtlas(const QgsFontTextureAtlas &other)
QgsFontTextureAtlas & operator=(const QgsFontTextureAtlas &other)