fix zero fonsize

This commit is contained in:
Andrii Vynychenko 2019-05-11 18:59:47 +03:00
parent a84649c0ee
commit 0353eb94ef
2 changed files with 14 additions and 1 deletions

View file

@ -1700,6 +1700,12 @@ public:
virtual void UploadEntityLayerText(int TextureID, const char *pText, int Length, float x, float y, int FontSize)
{
if (FontSize < 1)
{
dbg_msg("pFont", "texture with id '%d' will not be updated. Reason - font is too small", TextureID);
return;
}
const char *pCurrent = (char *)pText;
const char *pEnd = pCurrent + Length;
CFont *pFont = m_pDefaultFont;
@ -1715,7 +1721,7 @@ public:
{
unsigned int px, py;
FT_Set_Pixel_Sizes(pFont->m_FtFace, 0, FontSize-1);
FT_Set_Pixel_Sizes(pFont->m_FtFace, 0, FontSize);
if(FT_Load_Char(pFont->m_FtFace, NextCharacter, FT_LOAD_RENDER|FT_LOAD_NO_BITMAP))
{

View file

@ -182,6 +182,13 @@ int CMapImages::UploadEntityLayerText(int TextureSize, int YOffset)
int Len = str_format(aBuf, 4, "%d", 255);
int FontSize = TextRender()->AdjustFontSize(aBuf, Len, TextureSize);
if (FontSize < 1)
{
dbg_msg("pFont", "texture with id '%d' will not be loaded. Reason - font is too small", TextureID);
return TextureID;
}
YOffset += ((TextureSize - FontSize)/2);
for(int i = 0; i < 256; ++i)