已经可以使用freetype2.9设置字体的颜色,但是没有找到相关的设置字体背景色的方,有任何帮助感谢!!!下边是绘制带颜色的bitmap字符
for ( S32 n = 0; n < dataLength; n++)
{
PGlyph pplyph = glyphs+n;
FT_Vector pen = glyph->pos;
//error = FT_Glyph_To_Bitmap(&pplyph->glyph, FT_RENDER_MODE_NORMAL, &pen, 0);
error = FT_Glyph_To_Bitmap(&pplyph->glyph, FT_RENDER_MODE_NORMAL, &pen, 0);
if ( !error )
{
FT_BitmapGlyph bit = (FT_BitmapGlyph)pplyph->glyph;
start_x = pplyph->drawBox.xMin;
start_y = height - (pplyph->drawBox.yMin-bbox.yMin+bit->bitmap.rows);
for (S32 y = 0; y < bit->bitmap.rows; y++)
{
for (S32 x = 0; x < bit->bitmap.width; x++)
{
unsigned int iy = start_y + y;
unsigned int ix = start_x + x;
unsigned int index = (iy*width + ix)*4;
imageBuffer[index] = ~((dataIndexBuf[n].u32Foreground) & 0xFF);
imageBuffer[index+1] = ~(((dataIndexBuf[n].u32Foreground) >> 8) & 0xFF);
imageBuffer[index+2] = ~(((dataIndexBuf[n].u32Foreground) >> 16) & 0xFF);
imageBuffer[index+3] = bit->bitmap.buffer[y * bit->bitmap.width + x];
}
}
FT_Done_Glyph(pplyph->glyph);
}
}
https://blog.csdn.net/weixin_40550094/article/details/104071685