From 3431653791c5196a9eaafcf3d05576a912a99212 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 23 Nov 2017 09:05:17 -0800 Subject: [PATCH] UI: Draw actual, not aligned, text width. No need to overdraw. --- ext/native/gfx_es2/draw_text_win.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ext/native/gfx_es2/draw_text_win.cpp b/ext/native/gfx_es2/draw_text_win.cpp index 003086ad29..491e906625 100644 --- a/ext/native/gfx_es2/draw_text_win.cpp +++ b/ext/native/gfx_es2/draw_text_win.cpp @@ -305,10 +305,12 @@ void TextDrawerWin32::DrawString(DrawBuffer &target, const char *str, float x, f draw_->BindTexture(0, entry->texture); // Okay, the texture is bound, let's draw. - float w = entry->bmWidth * fontScaleX_ * dpiScale_; - float h = entry->bmHeight * fontScaleY_ * dpiScale_; + float w = entry->width * fontScaleX_ * dpiScale_; + float h = entry->height * fontScaleY_ * dpiScale_; + float u = entry->width / (float)entry->bmWidth; + float v = entry->height / (float)entry->bmHeight; DrawBuffer::DoAlign(align, &x, &y, &w, &h); - target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, 1.0f, 1.0f, color); + target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, u, v, color); target.Flush(true); } @@ -383,4 +385,4 @@ void TextDrawerWin32::OncePerFrame() { } } -#endif \ No newline at end of file +#endif