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)
_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)

View File

@ -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<FT_ULong>(_mssingGlyphCharacter));