Merge pull request #1126 from Jupeyy/master

Text fix
This commit is contained in:
Dennis Felsing 2018-05-09 08:53:05 +02:00 committed by GitHub
commit 44a8752929
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1555,22 +1555,19 @@ public:
{ {
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i]; STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i];
if(pTextOutlineColor->m_A != 0)
Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f * pTextOutlineColor->m_R, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f * pTextOutlineColor->m_G, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f * pTextOutlineColor->m_B, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f * pTextOutlineColor->m_A); Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f * pTextOutlineColor->m_R, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f * pTextOutlineColor->m_G, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f * pTextOutlineColor->m_B, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f * pTextOutlineColor->m_A);
else
Graphics()->SetColor(TextCharQuad.m_Vertices[0].m_Color.m_R / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_G / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_B / 255.f, TextCharQuad.m_Vertices[0].m_Color.m_A / 255.f);
Graphics()->QuadsSetSubset(TextCharQuad.m_Vertices[0].m_U * UVScale, TextCharQuad.m_Vertices[0].m_V * UVScale, TextCharQuad.m_Vertices[2].m_U * UVScale, TextCharQuad.m_Vertices[2].m_V * UVScale); Graphics()->QuadsSetSubset(TextCharQuad.m_Vertices[0].m_U * UVScale, TextCharQuad.m_Vertices[0].m_V * UVScale, TextCharQuad.m_Vertices[2].m_U * UVScale, TextCharQuad.m_Vertices[2].m_V * UVScale);
IGraphics::CQuadItem QuadItem(TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[0].m_Y, TextCharQuad.m_Vertices[1].m_X - TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[2].m_Y - TextCharQuad.m_Vertices[0].m_Y); IGraphics::CQuadItem QuadItem(TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[0].m_Y, TextCharQuad.m_Vertices[1].m_X - TextCharQuad.m_Vertices[0].m_X, TextCharQuad.m_Vertices[2].m_Y - TextCharQuad.m_Vertices[0].m_Y);
Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsDrawTL(&QuadItem, 1);
} }
if(pTextColor->m_A != 0)
{
Graphics()->QuadsEndKeepVertices(); Graphics()->QuadsEndKeepVertices();
Graphics()->TextureSet(pFont->m_aTextures[0]); Graphics()->TextureSet(pFont->m_aTextures[0]);
if(pTextColor->m_A != 0)
{
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i) for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
{ {
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i]; STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i];
@ -1580,22 +1577,13 @@ public:
unsigned char CA = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_A) * pTextColor->m_A); unsigned char CA = (unsigned char)((float)(TextCharQuad.m_Vertices[0].m_Color.m_A) * pTextColor->m_A);
Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA); Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA);
} }
}
else
{
for(size_t i = 0; i < TextContainer.m_StringInfo.m_QuadNum; ++i)
{
STextCharQuad& TextCharQuad = TextContainer.m_StringInfo.m_CharacterQuads[i];
unsigned char CR = TextCharQuad.m_Vertices[0].m_Color.m_R;
unsigned char CG = TextCharQuad.m_Vertices[0].m_Color.m_G;
unsigned char CB = TextCharQuad.m_Vertices[0].m_Color.m_B;
unsigned char CA = TextCharQuad.m_Vertices[0].m_Color.m_A;
Graphics()->ChangeColorOfQuadVertices((int)i, CR, CG, CB, CA);
}
}
// render non outlined // render non outlined
Graphics()->QuadsDrawCurrentVertices(false); Graphics()->QuadsDrawCurrentVertices(false);
}
else
Graphics()->QuadsEnd();
// reset // reset
Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); Graphics()->SetColor(1.f, 1.f, 1.f, 1.f);
@ -1748,9 +1736,14 @@ public:
{ {
// reset the skylines // reset the skylines
for(int j = 0; j < 2; ++j) for(int j = 0; j < 2; ++j)
{
for(size_t k = 0; k < m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn.size(); ++k) for(size_t k = 0; k < m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn.size(); ++k)
m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn[k] = 0; m_Fonts[i]->m_TextureSkyline[j].m_CurHeightOfPixelColumn[k] = 0;
mem_zero(m_Fonts[i]->m_TextureData[j], m_Fonts[i]->m_CurTextureDimensions[j] * m_Fonts[i]->m_CurTextureDimensions[j] * sizeof(unsigned char));
Graphics()->LoadTextureRawSub(m_Fonts[i]->m_aTextures[j], 0, 0, m_Fonts[i]->m_CurTextureDimensions[j], m_Fonts[i]->m_CurTextureDimensions[j], CImageInfo::FORMAT_ALPHA, m_Fonts[i]->m_TextureData[j]);
}
m_Fonts[i]->InitFontSizes(); m_Fonts[i]->InitFontSizes();
} }
} }