Improve code style

This commit is contained in:
halx99 2022-06-13 14:28:09 +08:00
parent 864c73154c
commit 6c63c55abb
2 changed files with 14 additions and 18 deletions

View File

@ -95,7 +95,7 @@ void FontAtlas::reinit()
{ {
if (!_currentPageData) if (!_currentPageData)
_currentPageData = new uint8_t[_currentPageDataSize]; _currentPageData = new uint8_t[_currentPageDataSize];
_currentPage = -1; _currentPage = -1;
#if defined(CC_USE_METAL) #if defined(CC_USE_METAL)
if (_strideShift && !_currentPageDataRGBA) if (_strideShift && !_currentPageDataRGBA)
@ -281,32 +281,29 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
tempDef.U = tempDef.U / scaleFactor; tempDef.U = tempDef.U / scaleFactor;
tempDef.V = tempDef.V / scaleFactor; tempDef.V = tempDef.V / scaleFactor;
tempDef.rotated = false; tempDef.rotated = false;
updateTextureContent(pixelFormat, startY);
} }
else else
{ // don't render anythings {
if (bitmap) if (bitmap)
delete[] bitmap; delete[] bitmap;
if (tempDef.xAdvance)
tempDef.validDefinition = true;
else
tempDef.validDefinition = false;
tempDef.width = 0; tempDef.validDefinition = !!tempDef.xAdvance;
tempDef.height = 0; tempDef.width = 0;
tempDef.U = 0; tempDef.height = 0;
tempDef.V = 0; tempDef.U = 0;
tempDef.offsetX = 0; tempDef.V = 0;
tempDef.offsetY = 0; tempDef.offsetX = 0;
tempDef.textureID = 0; tempDef.offsetY = 0;
tempDef.rotated = false; tempDef.textureID = 0;
tempDef.rotated = false;
_currentPageOrigX += 1; _currentPageOrigX += 1;
} }
_letterDefinitions[charCode] = tempDef; _letterDefinitions[charCode] = tempDef;
} }
updateTextureContent(pixelFormat, startY);
return true; return true;
} }
@ -371,7 +368,6 @@ void FontAtlas::addNewPage()
texture->release(); texture->release();
_currentPageOrigY = 0; _currentPageOrigY = 0;
} }
void FontAtlas::setTexture(unsigned int slot, Texture2D* texture) void FontAtlas::setTexture(unsigned int slot, Texture2D* texture)

View File

@ -404,7 +404,7 @@ unsigned char* FontFreeType::getGlyphBitmap(char32_t charCode,
if (_mssingGlyphCharacter != 0) if (_mssingGlyphCharacter != 0)
{ {
if (_mssingGlyphCharacter == 0x1A) 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 // Try get new glyph index with missing glyph character code
glyphIndex = FT_Get_Char_Index(_fontFace, static_cast<FT_ULong>(_mssingGlyphCharacter)); glyphIndex = FT_Get_Char_Index(_fontFace, static_cast<FT_ULong>(_mssingGlyphCharacter));