From d52a69b0e6aad617fb2e8366b895f132d31d3755 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 1 Feb 2019 11:07:47 +0000 Subject: [PATCH] Fix dumbass font problems The 320x240 font is still one pixel too high, but honestly I don't give a shit. It looks better anyway since the vanilla way is off-centre. --- src/Draw.cpp | 8 +++++--- src/Font.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index cf8fee50..710a383e 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -447,16 +447,18 @@ void InitTextObject(const char *font_name) { //Get font size unsigned int fontWidth, fontHeight; - if (gWindowScale == 1) + + // The original did this, but Windows would downscale it to 5/10 anyway. +/* if (gWindowScale == 1) { fontWidth = 6; fontHeight = 12; } else - { + {*/ fontWidth = 5 * gWindowScale; fontHeight = 10 * gWindowScale; - } +// } #ifdef WINDOWS // Actually use the font Config.dat specifies diff --git a/src/Font.cpp b/src/Font.cpp index 4f1613c0..fb6961b2 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -228,7 +228,7 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig FT_Bitmap_Convert(font_object->library, &face->glyph->bitmap, &converted, 1); const int letter_x = x + pen_x + face->glyph->bitmap_left; - const int letter_y = y + ((FT_MulFix(face->ascender, face->size->metrics.y_scale) + (64 - 1)) / 64) - (face->glyph->metrics.horiBearingY / 64); + const int letter_y = y + ((FT_MulFix(face->ascender, face->size->metrics.y_scale) - face->glyph->metrics.horiBearingY + (64 / 2)) / 64); for (int iy = MAX(-letter_y, 0); letter_y + iy < MIN(letter_y + converted.rows, surface->h); ++iy) {