diff --git a/core/2d/CCFontAtlas.cpp b/core/2d/CCFontAtlas.cpp index cc66494bd7..b9bade7a58 100644 --- a/core/2d/CCFontAtlas.cpp +++ b/core/2d/CCFontAtlas.cpp @@ -95,7 +95,7 @@ void FontAtlas::reinit() { if (!_currentPageData) _currentPageData = new uint8_t[_currentPageDataSize]; - _currentPage = -1; + _currentPage = -1; #if defined(CC_USE_METAL) if (_strideShift && !_currentPageDataRGBA) @@ -281,32 +281,29 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text) tempDef.U = tempDef.U / scaleFactor; tempDef.V = tempDef.V / scaleFactor; tempDef.rotated = false; - - updateTextureContent(pixelFormat, startY); } else - { // don't render anythings + { if (bitmap) delete[] bitmap; - if (tempDef.xAdvance) - tempDef.validDefinition = true; - else - tempDef.validDefinition = false; - tempDef.width = 0; - tempDef.height = 0; - tempDef.U = 0; - tempDef.V = 0; - tempDef.offsetX = 0; - tempDef.offsetY = 0; - tempDef.textureID = 0; - tempDef.rotated = false; + tempDef.validDefinition = !!tempDef.xAdvance; + tempDef.width = 0; + tempDef.height = 0; + tempDef.U = 0; + tempDef.V = 0; + tempDef.offsetX = 0; + tempDef.offsetY = 0; + tempDef.textureID = 0; + tempDef.rotated = false; _currentPageOrigX += 1; } _letterDefinitions[charCode] = tempDef; } + updateTextureContent(pixelFormat, startY); + return true; } @@ -371,7 +368,6 @@ void FontAtlas::addNewPage() texture->release(); _currentPageOrigY = 0; - } void FontAtlas::setTexture(unsigned int slot, Texture2D* texture) diff --git a/core/2d/CCFontFreeType.cpp b/core/2d/CCFontFreeType.cpp index 64966e2cef..a14a8ac3d2 100644 --- a/core/2d/CCFontFreeType.cpp +++ b/core/2d/CCFontFreeType.cpp @@ -404,7 +404,7 @@ unsigned char* FontFreeType::getGlyphBitmap(char32_t charCode, if (_mssingGlyphCharacter != 0) { if (_mssingGlyphCharacter == 0x1A) - return nullptr; // don't render anything for this character + break; // don't render anything for this character // Try get new glyph index with missing glyph character code glyphIndex = FT_Get_Char_Index(_fontFace, static_cast(_mssingGlyphCharacter));