From 826e9d2ee1dc9258dcfa6d294b5a3dfa21fe63c4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 23 Nov 2017 09:04:15 -0800 Subject: [PATCH] UI: Clear font bitmap after aligning size. Otherwise we get remnants from previous draws, oops. --- ext/native/gfx_es2/draw_text_win.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/native/gfx_es2/draw_text_win.cpp b/ext/native/gfx_es2/draw_text_win.cpp index 0b500af293..003086ad29 100644 --- a/ext/native/gfx_es2/draw_text_win.cpp +++ b/ext/native/gfx_es2/draw_text_win.cpp @@ -227,14 +227,6 @@ void TextDrawerWin32::DrawString(DrawBuffer &target, const char *str, float x, f size.cx = textRect.right; size.cy = textRect.bottom; - // GetTextExtentPoint32(ctx_->hDC, wstr.c_str(), (int)wstr.size(), &size); - RECT rc = { 0 }; - rc.right = size.cx + 4; - rc.bottom = size.cy + 4; - FillRect(ctx_->hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); - //ExtTextOut(ctx_->hDC, 0, 0, ETO_OPAQUE | ETO_CLIPPED, NULL, wstr.c_str(), (int)wstr.size(), NULL); - DrawTextExW(ctx_->hDC, (LPWSTR)wstr.c_str(), (int)wstr.size(), &rc, DT_HIDEPREFIX | DT_TOP | dtAlign, 0); - if (size.cx > MAX_TEXT_WIDTH) size.cx = MAX_TEXT_WIDTH; if (size.cy > MAX_TEXT_HEIGHT) @@ -247,6 +239,12 @@ void TextDrawerWin32::DrawString(DrawBuffer &target, const char *str, float x, f entry->bmHeight = (size.cy + 3) & ~3; entry->lastUsedFrame = frameCount_; + RECT rc = { 0 }; + rc.right = entry->bmWidth; + rc.bottom = entry->bmHeight; + FillRect(ctx_->hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + DrawTextExW(ctx_->hDC, (LPWSTR)wstr.c_str(), (int)wstr.size(), &rc, DT_HIDEPREFIX | DT_TOP | dtAlign, 0); + DataFormat texFormat; // For our purposes these are equivalent, so just choose the supported one. D3D can emulate them. if (draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16) & FMT_TEXTURE)