原来只是以左上对齐点,宽高各偏移描边的厚度大小。但是这样会出现在一些字体与背景阴影字对不齐的情况。
上面第一行:能、好、连、败,显示是不对的。下面一行是修正后的。
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance)
{
bool invalidChar = true;
unsigned char * ret = nullptr;
do
{
if (!_fontRef)
break;
auto glyphIndex = FT_Get_Char_Index(_fontRef, theChar);
if(!glyphIndex)
break;
if (_distanceFieldEnabled)
{
if (FT_Load_Glyph(_fontRef,glyphIndex,FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT))
break;
}
else
{
if (FT_Load_Glyph(_fontRef,glyphIndex,FT_LOAD_RENDER))
break;
}
outRect.origin.x = _fontRef->glyph->