class freetype.Glyph(glyph)

FT_Glyph wrapper.

The root glyph structure contains a given glyph image plus its advance width in 16.16 fixed float format.


The format of the glyph’s image.


Return an outline’s ‘control box’. The control box encloses all the outline’s points, including Bezier control points. Though it coincides with the exact bounding box for most glyphs, it can be slightly larger in some situations (like when rotating an outline which contains Bezier outside arcs).

Computing the control box is very fast, while getting the bounding box can take much more time as it needs to walk over all segments and arcs in the outline. To get the latter, you can use the ‘ftbbox’ component which is dedicated to this single task.

Parameters:mode – The mode which indicates how to interpret the returned bounding box values.


Coordinates are relative to the glyph origin, using the y upwards convention.

If the glyph has been loaded with FT_LOAD_NO_SCALE, ‘bbox_mode’ must be set to FT_GLYPH_BBOX_UNSCALED to get unscaled font units in 26.6 pixel format. The value FT_GLYPH_BBOX_SUBPIXELS is another name for this constant.

Note that the maximum coordinates are exclusive, which means that one can compute the width and height of the glyph image (be it in integer or 26.6 pixels) as:

width = bbox.xMax - bbox.xMin; height = bbox.yMax - bbox.yMin;

Note also that for 26.6 coordinates, if ‘bbox_mode’ is set to FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, which corresponds to:

bbox.xMin = FLOOR(bbox.xMin); bbox.yMin = FLOOR(bbox.yMin); bbox.xMax = CEILING(bbox.xMax); bbox.yMax = CEILING(bbox.yMax);

To get the bbox in pixel coordinates, set ‘bbox_mode’ to FT_GLYPH_BBOX_TRUNCATE.

To get the bbox in grid-fitted pixel coordinates, set ‘bbox_mode’ to FT_GLYPH_BBOX_PIXELS.

stroke(stroker, destroy=False)

Stroke a given outline glyph object with a given stroker.

  • stroker – A stroker handle.
  • destroy – A Boolean. If 1, the source glyph object is destroyed on success.


The source glyph is untouched in case of error.
to_bitmap(mode, origin, destroy=False)

Convert a given glyph object to a bitmap glyph object.

  • mode – An enumeration that describes how the data is rendered.
  • origin

    A pointer to a vector used to translate the glyph image before rendering. Can be 0 (if no translation). The origin is expressed in 26.6 pixels.

    We also detect a plain vector and make a pointer out of it, if that’s the case.

  • destroy – A boolean that indicates that the original glyph image should be destroyed by this function. It is never destroyed in case of error.


This function does nothing if the glyph format isn’t scalable.

The glyph image is translated with the ‘origin’ vector before rendering.

The first parameter is a pointer to an FT_Glyph handle, that will be replaced by this function (with newly allocated data). Typically, you would use (omitting error handling):