Skip to content

Commit

Permalink
Fix UnicodeTextImage::createFont crash on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 authored and YaLTeR committed Nov 1, 2020
1 parent ba5f22c commit 71b26e5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cl_dll/vgui_UnicodeTextImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class IHTML;
class IHTMLEvents;
class VGuiVertex;

}

namespace vgui2
{

class ISurface : public IBaseInterface
{
public:
Expand Down Expand Up @@ -246,14 +251,19 @@ class ILocalize : public IBaseInterface

#define VGUI_LOCALIZE_INTERFACE_VERSION "VGUI_Localize003"

}

namespace
{

bool g_bSurfaceLoaded = false;

// hw.dll or sw.dll on Windows, hw.so on Linux, hw.dylib on macOS.
CSysModule *g_hEngineModule = nullptr;
CSysModule *g_hVGuiModule = nullptr;

ISurface *g_pVGuiSurface = nullptr;
ILocalize *g_pVGuiLocalize = nullptr;
vgui2::ISurface *g_pVGuiSurface = nullptr;
vgui2::ILocalize *g_pVGuiLocalize = nullptr;

}

Expand Down Expand Up @@ -328,7 +338,7 @@ void UnicodeTextImage::initInterfaces()
}

pIface = static_cast<IfaceType>(fnFactory(ifaceName, nullptr));
if (!g_pVGuiSurface)
if (!pIface)
{
gEngfuncs.Con_Printf("UnicodeTextImage: Error: %s doesn't export %s.\n", moduleName, ifaceName);
return false;
Expand Down Expand Up @@ -360,7 +370,7 @@ UnicodeTextImage::HFont UnicodeTextImage::createFont(const char *fontName, int t

int flags = 0;
if (tall >= MIN_AA_FONT_SIZE)
flags |= ISurface::FONTFLAG_ANTIALIAS;
flags |= vgui2::ISurface::FONTFLAG_ANTIALIAS;

HFont font = g_pVGuiSurface->CreateFont();
g_pVGuiSurface->AddGlyphSetToFont(font, fontName, tall, weight, 0, 0, flags, 0, 0);
Expand Down

0 comments on commit 71b26e5

Please sign in to comment.