mirror of https://github.com/axmolengine/axmol.git
Label:Fixed create fail if the font(TTF) not contain a Unicode charmap.
This commit is contained in:
parent
268605270e
commit
81bc0b09da
|
@ -137,9 +137,28 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
||||||
if (FT_New_Memory_Face(getFTLibrary(), s_cacheFontData[fontName].data.getBytes(), s_cacheFontData[fontName].data.getSize(), 0, &face ))
|
if (FT_New_Memory_Face(getFTLibrary(), s_cacheFontData[fontName].data.getBytes(), s_cacheFontData[fontName].data.getSize(), 0, &face ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//we want to use unicode
|
|
||||||
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))
|
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))
|
||||||
return false;
|
{
|
||||||
|
int foundIndex = -1;
|
||||||
|
for (int charmapIndex = 0; charmapIndex < face->num_charmaps; charmapIndex++)
|
||||||
|
{
|
||||||
|
if (face->charmaps[charmapIndex]->encoding != FT_ENCODING_NONE)
|
||||||
|
{
|
||||||
|
foundIndex = charmapIndex;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundIndex == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FT_Select_Charmap(face, face->charmaps[foundIndex]->encoding))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set the requested font size
|
// set the requested font size
|
||||||
int dpi = 72;
|
int dpi = 72;
|
||||||
|
|
|
@ -481,6 +481,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false *
|
||||||
|
|
||||||
if (_fontAtlas)
|
if (_fontAtlas)
|
||||||
{
|
{
|
||||||
|
_batchNodes.clear();
|
||||||
FontAtlasCache::releaseFontAtlas(_fontAtlas);
|
FontAtlasCache::releaseFontAtlas(_fontAtlas);
|
||||||
_fontAtlas = nullptr;
|
_fontAtlas = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue