unsigned char* buffer; ///< The glyph's bitmap buffer data.
unsigned int width; ///< The width of the bitmap.
unsigned int height; ///< The height of the bitmap.
+ int outlineOffsetX; ///< The additional horizontal offset to be added for the glyph's position for outline.
+ int outlineOffsetY; ///< The additional vertical offset to be added for the glyph's position for outline.
Pixel::Format format; ///< The pixel's format of the bitmap.
bool isColorEmoji:1; ///< Whether the glyph is an emoji.
bool isColorBitmap:1; ///< Whether the glyph is a color bitmap.
{
if( glyph->format != FT_GLYPH_FORMAT_BITMAP )
{
- // Check whether we should create a bitmap for the outline
- if( glyph->format == FT_GLYPH_FORMAT_OUTLINE && outlineWidth > 0 )
+ int offsetX, offsetY;
+ bool isOutlineGlyph = ( glyph->format == FT_GLYPH_FORMAT_OUTLINE && outlineWidth > 0 );
+
+ // Create a bitmap for the outline
+ if( isOutlineGlyph )
{
+ // Retrieve the horizontal and vertical distance from the current pen position to the
+ // left and top border of the glyph bitmap for a normal glyph before applying the outline.
+ if( FT_Err_Ok == error )
+ {
+ FT_Glyph normalGlyph;
+ error = FT_Get_Glyph( ftFace->glyph, &normalGlyph );
+
+ error = FT_Glyph_To_Bitmap( &normalGlyph, FT_RENDER_MODE_NORMAL, 0, 1 );
+ if( FT_Err_Ok == error )
+ {
+ FT_BitmapGlyph bitmapGlyph = reinterpret_cast< FT_BitmapGlyph >( normalGlyph );
+
+ offsetX = bitmapGlyph->left;
+ offsetY = bitmapGlyph->top;
+ }
+
+ // Created FT_Glyph object must be released with FT_Done_Glyph
+ FT_Done_Glyph( normalGlyph );
+ }
+
+ // Now apply the outline
+
// Set up a stroker
FT_Stroker stroker;
error = FT_Stroker_New( mFreeTypeLibrary, &stroker );
if( FT_Err_Ok == error )
{
FT_BitmapGlyph bitmapGlyph = reinterpret_cast< FT_BitmapGlyph >( glyph );
+
+ if( isOutlineGlyph )
+ {
+ // Calculate the additional horizontal and vertical offsets needed for the position of the outline glyph
+ data.outlineOffsetX = offsetX - bitmapGlyph->left - outlineWidth;
+ data.outlineOffsetY = bitmapGlyph->top - offsetY - outlineWidth;
+ }
+
ConvertBitmap( data, bitmapGlyph->bitmap, isShearRequired );
}
else