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):
FT_Glyph glyph;
FT_BitmapGlyph glyph_bitmap;
// load glyph
error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT );
// extract glyph image
error = FT_Get_Glyph( face->glyph, &glyph );
// convert to a bitmap (default render mode + destroying old)
if ( glyph->format != FT_GLYPH_FORMAT_BITMAP )
{
error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL,
0, 1 );
if ( error ) // `glyph' unchanged
...
}
// access bitmap content by typecasting
glyph_bitmap = (FT_BitmapGlyph)glyph;
// do funny stuff with it, like blitting/drawing
...
// discard glyph image (bitmap or not)
FT_Done_Glyph( glyph );
Here another example, again without error handling:
FT_Glyph glyphs[MAX_GLYPHS]
...
for ( idx = 0; i < MAX_GLYPHS; i++ )
error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) ||
FT_Get_Glyph ( face->glyph, &glyph[idx] );
...
for ( idx = 0; i < MAX_GLYPHS; i++ )
{
FT_Glyph bitmap = glyphs[idx];
...
// after this call, `bitmap' no longer points into
// the `glyphs' array (and the old value isn't destroyed)
FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 );
...
FT_Done_Glyph( bitmap );
}
...
for ( idx = 0; i < MAX_GLYPHS; i++ )
FT_Done_Glyph( glyphs[idx] );
|