Skip to content
Permalink
Browse files

Fix text extent calculation for drawing colorcoded text

  • Loading branch information...
botder committed Jul 29, 2019
1 parent 709bc40 commit c9e2e2a95a3d076e69b4e6252d8ba81752fd2fae
Showing with 7 additions and 5 deletions.
  1. +7 −5 Client/core/Graphics/CGraphics.cpp
@@ -673,20 +673,22 @@ float CGraphics::GetDXTextExtent(const char* szText, float fScale, LPD3DXFONT pD

float CGraphics::GetDXTextExtentW(const wchar_t* wszText, float fScale, LPD3DXFONT pDXFont)
{
if (*wszText == L'\0')
return 0.0f;

if (!pDXFont)
pDXFont = GetFont();

pDXFont = MaybeGetBigFont(pDXFont, fScale, fScale);

if (pDXFont)
{
HDC dc = pDXFont->GetDC();
SIZE size;
RECT rect = {};
pDXFont->DrawTextW(nullptr, wszText, wcslen(wszText), &rect, DT_CALCRECT | DT_SINGLELINE, D3DCOLOR_XRGB(0, 0, 0));

GetTextExtentPoint32W(dc, wszText, wcslen(wszText), &size);

return ((float)size.cx * fScale);
return static_cast<float>(rect.right - rect.left) * fScale;
}

return 0.0f;
}

0 comments on commit c9e2e2a

Please sign in to comment.
You can’t perform that action at this time.