diff --git a/src/Drawer2D.c b/src/Drawer2D.c index f353c242a..bcee951c5 100644 --- a/src/Drawer2D.c +++ b/src/Drawer2D.c @@ -139,13 +139,20 @@ void Drawer2D_SetFontBitmap(Bitmap* bmp) { Drawer2D_CalculateTextWidths(); } +void Font_ReducePadding(struct FontDesc* desc, int scale) { + int padding; + if (!Drawer2D_BitmappedText) return; + + padding = (desc->height - desc->size) / scale; + desc->height -= padding * 2; +} + /* Measures width of the given text when drawn with the given system font. */ static int Font_SysTextWidth(struct DrawTextArgs* args); /* Draws the given text with the given system font onto the given bitmap. */ static int Font_SysTextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow); - /*########################################################################################################################* *---------------------------------------------------Drawing functions-----------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/Drawer2D.h b/src/Drawer2D.h index 0907e0abc..6c680c1c2 100644 --- a/src/Drawer2D.h +++ b/src/Drawer2D.h @@ -101,6 +101,8 @@ void Drawer2D_SetFontBitmap(Bitmap* bmp); /* Gets the list of all supported system font names on this platform. */ void Font_GetNames(StringsBuffer* buffer); +/* Reduces padding for a bitmapped font. */ +void Font_ReducePadding(struct FontDesc* desc, int scale); /* Finds the path and face number of the given system font, with closest matching style */ String Font_Lookup(const String* fontName, int style); /* Allocates a new system font from the given arguments. */ diff --git a/src/Gui.c b/src/Gui.c index 3a82a216e..735b1ce1d 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -341,7 +341,6 @@ void TextAtlas_Make(struct TextAtlas* atlas, const String* chars, struct FontDes } Mem_Free(bmp.Scan0); - Drawer2D_ReducePadding_Tex(&atlas->tex, font->size, 4); atlas->uScale = 1.0f / (float)bmp.Width; atlas->tex.uv.U2 = atlas->offset * atlas->uScale; atlas->tex.Width = atlas->offset; diff --git a/src/Menus.c b/src/Menus.c index 2f099f794..d31475d91 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -2807,6 +2807,7 @@ static void TexIdsOverlay_ContextRecreated(void* screen) { s->dynamicVb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FT2FC4B, TEXID_OVERLAY_VERTICES_COUNT); Drawer2D_MakeFont(&textFont, 8, FONT_STYLE_NORMAL); + Font_ReducePadding(&textFont, 4); TextAtlas_Make(&s->idAtlas, &chars, &textFont, &prefix); Font_Free(&textFont); diff --git a/src/Program.c b/src/Program.c index c02089e19..22a27b6ac 100644 --- a/src/Program.c +++ b/src/Program.c @@ -107,8 +107,8 @@ static int Program_Run(int argc, char** argv) { #ifdef _MSC_VER /* NOTE: Make sure to comment this out before pushing a commit */ //String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565"); - //String rawArgs = String_FromConst("UnknownShadow200"); - //argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4); + String rawArgs = String_FromConst("UnknownShadow200"); + argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4); #endif if (argsCount == 0) { diff --git a/src/Screens.c b/src/Screens.c index 742efc0e4..0f05e3851 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -355,10 +355,10 @@ static void StatusScreen_ContextRecreated(void* screen) { struct TextWidget* line2 = &s->line2; int y; Drawer2D_MakeFont(&s->font, 16, FONT_STYLE_NORMAL); + Font_ReducePadding(&s->font, 4); y = 2; TextWidget_Make(line1, ANCHOR_MIN, ANCHOR_MIN, 2, y); - line1->reducePadding = true; StatusScreen_Update(s, 1.0); y += line1->height; @@ -367,7 +367,6 @@ static void StatusScreen_ContextRecreated(void* screen) { y += s->posAtlas.tex.Height; TextWidget_Make(line2, ANCHOR_MIN, ANCHOR_MIN, 2, y); - line2->reducePadding = true; if (Game_ClassicMode) { /* Swap around so 0.30 version is at top */ diff --git a/src/Widgets.c b/src/Widgets.c index f29c98414..3af51f846 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -70,10 +70,6 @@ void TextWidget_Set(struct TextWidget* w, const String* text, struct FontDesc* f Drawer2D_MakeTextTexture(&w->tex, &args); } - if (w->reducePadding) { - Drawer2D_ReducePadding_Tex(&w->tex, font->size, 4); - } - w->width = w->tex.Width; w->height = w->tex.Height; Widget_Reposition(w); } diff --git a/src/Widgets.h b/src/Widgets.h index 4fff34bc5..a3be9e2b0 100644 --- a/src/Widgets.h +++ b/src/Widgets.h @@ -13,7 +13,6 @@ struct FontDesc; struct TextWidget { Widget_Layout struct Texture tex; - bool reducePadding; PackedCol col; }; /* Initialises a text widget. */