mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix client crash when starting without font file
Add checks to text render functions to prevent crashes when no default font is set.
This commit is contained in:
parent
5db9f029e4
commit
d203f38f01
|
@ -1714,6 +1714,8 @@ public:
|
|||
|
||||
void UploadEntityLayerText(void *pTexBuff, size_t ImageColorChannelCount, int TexWidth, int TexHeight, int TexSubWidth, int TexSubHeight, const char *pText, int Length, float x, float y, int FontSize) override
|
||||
{
|
||||
if(m_pDefaultFont == nullptr)
|
||||
return;
|
||||
if(FontSize < 1)
|
||||
return;
|
||||
|
||||
|
@ -1796,6 +1798,9 @@ public:
|
|||
|
||||
float GetGlyphOffsetX(int FontSize, char TextCharacter) const override
|
||||
{
|
||||
if(m_pDefaultFont == nullptr)
|
||||
return -1;
|
||||
|
||||
const CFont *pFont = m_pDefaultFont;
|
||||
FT_Set_Pixel_Sizes(pFont->m_FtFace, 0, FontSize);
|
||||
const char *pTmp = &TextCharacter;
|
||||
|
@ -1821,6 +1826,9 @@ public:
|
|||
|
||||
int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontHeight) const override
|
||||
{
|
||||
if(m_pDefaultFont == nullptr)
|
||||
return 0;
|
||||
|
||||
const CFont *pFont = m_pDefaultFont;
|
||||
const char *pCurrent = pText;
|
||||
const char *pEnd = pCurrent + TextLength;
|
||||
|
|
Loading…
Reference in a new issue