Permalink
Browse files

UI: Clear font bitmap after aligning size.

Otherwise we get remnants from previous draws, oops.
  • Loading branch information...
unknownbrackets committed Nov 23, 2017
1 parent c04ead1 commit 826e9d2ee1dc9258dcfa6d294b5a3dfa21fe63c4
Showing with 6 additions and 8 deletions.
  1. +6 −8 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)

0 comments on commit 826e9d2

Please sign in to comment.