Class: QgsFontTextureAtlas

Encapsulates a font texture atlas.

QgsFontTextureAtlas contains the packed texture atlas for a font, along with the associated text metrics for rendering.

See QgsFontTextureAtlasGenerator for a class which automatically creates texture atlases.

Added in version 4.0.

Methods

atlasSize

Returns the total size required for the atlas, i.e. the total size for the texture.

count

Returns the number of textures in the atlas.

graphemeCount

Returns the number of graphemes to render for a given string.

isValid

Returns True if the atlas is valid.

pixelOffsetForGrapheme

Returns the pixel offset at which the texture for the matching grapheme should be placed.

rect

Returns the packed rectangle for the texture for the specified grapheme.

renderAtlasTexture

Renders the combined texture atlas, containing all required characters.

renderDebugTexture

Renders a debug texture.

textureRectForGrapheme

Returns the packed rectangle for the texture for the matching grapheme.

class qgis._3d.QgsFontTextureAtlas[source]

Bases: object

atlasSize(self) QSize[source]

Returns the total size required for the atlas, i.e. the total size for the texture.

Return type:

QSize

count(self) int[source]

Returns the number of textures in the atlas.

Return type:

int

graphemeCount(self, string: str | None) int[source]

Returns the number of graphemes to render for a given string.

The string must match one of the strings passed to QgsFontTextureAtlasGenerator when creating the texture atlas.

Parameters:

string (Optional[str])

Return type:

int

isValid(self) bool[source]

Returns True if the atlas is valid.

Return type:

bool

pixelOffsetForGrapheme(self, string: str | None, graphemeIndex: int) QPoint[source]

Returns the pixel offset at which the texture for the matching grapheme should be placed.

The string must match one of the strings passed to QgsFontTextureAtlasGenerator when creating the texture atlas.

Parameters:
  • string (Optional[str])

  • graphemeIndex (int)

Return type:

QPoint

rect(self, grapheme: str | None) QRect[source]

Returns the packed rectangle for the texture for the specified grapheme.

Raises:

KeyError – if no texture for the specified grapheme exists.

Parameters:

grapheme (Optional[str])

Return type:

QRect

renderAtlasTexture(self) QImage[source]

Renders the combined texture atlas, containing all required characters.

Return type:

QImage

renderDebugTexture(self) QImage[source]

Renders a debug texture.

The debug texture renders all packed character rectangles with a unique color, and can be used to visualize the solution.

Return type:

QImage

textureRectForGrapheme(self, string: str | None, graphemeIndex: int) QRect[source]

Returns the packed rectangle for the texture for the matching grapheme.

The string must match one of the strings passed to QgsFontTextureAtlasGenerator when creating the texture atlas.

Parameters:
  • string (Optional[str])

  • graphemeIndex (int)

Return type:

QRect