Merge pull request #14914 from steerlink/font_family

Add ability to get the font family
This commit is contained in:
zilongshanren 2016-01-21 10:34:13 +08:00
commit e1e87c0205
2 changed files with 10 additions and 1 deletions

View File

@ -274,6 +274,14 @@ int FontFreeType::getFontAscender() const
return (static_cast<int>(_fontRef->size->metrics.ascender >> 6));
}
const char* FontFreeType::getFontFamily() const
{
if (!_fontRef)
return nullptr;
return _fontRef->family_name;
}
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance)
{
bool invalidChar = true;
@ -639,7 +647,7 @@ void FontFreeType::releaseFont(const std::string &fontName)
auto item = s_cacheFontData.begin();
while (s_cacheFontData.end() != item)
{
if (item->first.find(fontName) >= 0)
if (item->first.find(fontName) != std::string::npos)
item = s_cacheFontData.erase(item);
else
item++;

View File

@ -71,6 +71,7 @@ public:
unsigned char* getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance);
int getFontAscender() const;
const char* getFontFamily() const;
virtual FontAtlas* createFontAtlas() override;
virtual int getFontMaxHeight() const override { return _lineHeight; }