Skip to content

Commit 71b26e5

Browse files
tmp64YaLTeR
authored andcommitted
Fix UnicodeTextImage::createFont crash on Linux
1 parent ba5f22c commit 71b26e5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

cl_dll/vgui_UnicodeTextImage.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class IHTML;
3434
class IHTMLEvents;
3535
class VGuiVertex;
3636

37+
}
38+
39+
namespace vgui2
40+
{
41+
3742
class ISurface : public IBaseInterface
3843
{
3944
public:
@@ -246,14 +251,19 @@ class ILocalize : public IBaseInterface
246251

247252
#define VGUI_LOCALIZE_INTERFACE_VERSION "VGUI_Localize003"
248253

254+
}
255+
256+
namespace
257+
{
258+
249259
bool g_bSurfaceLoaded = false;
250260

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

255-
ISurface *g_pVGuiSurface = nullptr;
256-
ILocalize *g_pVGuiLocalize = nullptr;
265+
vgui2::ISurface *g_pVGuiSurface = nullptr;
266+
vgui2::ILocalize *g_pVGuiLocalize = nullptr;
257267

258268
}
259269

@@ -328,7 +338,7 @@ void UnicodeTextImage::initInterfaces()
328338
}
329339

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

361371
int flags = 0;
362372
if (tall >= MIN_AA_FONT_SIZE)
363-
flags |= ISurface::FONTFLAG_ANTIALIAS;
373+
flags |= vgui2::ISurface::FONTFLAG_ANTIALIAS;
364374

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

0 commit comments

Comments
 (0)