From 36ce5aa4e7f5a089561c336cd670f2628c8d2d5b Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 27 Jan 2019 15:29:59 +0100 Subject: [PATCH] Fix font outlines/size --- include/visual/drawing.hpp | 5 +++-- src/visual/drawing.cpp | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/visual/drawing.hpp b/include/visual/drawing.hpp index f9961a32..3687e241 100644 --- a/include/visual/drawing.hpp +++ b/include/visual/drawing.hpp @@ -29,13 +29,14 @@ namespace fonts #if ENABLE_ENGINE_DRAWING struct font { - font(std::string path, int fontsize) : size{ fontsize }, path{ path } + font(std::string path, int fontsize, bool outline = false) : size{ fontsize }, path{ path }, outline{ outline } { } unsigned int id; std::string path; int size; - bool init = false; + bool init = false; + bool outline = false; operator unsigned int(); void stringSize(std::string string, float *x, float *y); void Init(); diff --git a/src/visual/drawing.cpp b/src/visual/drawing.cpp index ca4ee22c..75a0c12c 100644 --- a/src/visual/drawing.cpp +++ b/src/visual/drawing.cpp @@ -90,11 +90,12 @@ font::operator unsigned int() } void font::Init() { - size += 1; + size += 3; static std::string filename; filename.append("ab"); - id = g_ISurface->CreateFont(); - g_ISurface->SetFontGlyphSet(id, filename.c_str(), size, 500, 0, 0, vgui::ISurface::FONTFLAG_ANTIALIAS | vgui::ISurface::FONTFLAG_ADDITIVE); + id = g_ISurface->CreateFont(); + auto flag = outline ? vgui::ISurface::FONTFLAG_OUTLINE | vgui::ISurface::FONTFLAG_ANTIALIAS : vgui::ISurface::FONTFLAG_ANTIALIAS; + g_ISurface->SetFontGlyphSet(id, filename.c_str(), size, 500, 0, 0, flag); g_ISurface->AddCustomFontFile(filename.c_str(), path.c_str()); init = true; } @@ -130,8 +131,8 @@ void Initialize() #if !ENABLE_ENGINE_DRAWING glez::preInit(); #endif - fonts::menu.reset(new fonts::font(DATA_PATH "/fonts/verasans.ttf", 14)); - fonts::esp.reset(new fonts::font(DATA_PATH "/fonts/verasans.ttf", 14)); + fonts::menu.reset(new fonts::font(DATA_PATH "/fonts/verasans.ttf", 14, true)); + fonts::esp.reset(new fonts::font(DATA_PATH "/fonts/verasans.ttf", 14, true)); texture_white = g_ISurface->CreateNewTextureID(); unsigned char colorBuffer[4] = { 255, 255, 255, 255 }; @@ -144,7 +145,7 @@ void String(int x, int y, rgba_t rgba, const char *text, fonts::font &font) glez::draw::outlined_string(x, y, text, font, rgba, colors::black, nullptr, nullptr); #else rgba = rgba * 255.0f; - g_ISurface->DrawSetTextPos(x, y); + g_ISurface->DrawSetTextPos(x, y - 2); g_ISurface->DrawSetTextFont(font); g_ISurface->DrawSetTextColor(rgba.r, rgba.g, rgba.b, rgba.a);