Skip to content

Commit 31b20b4

Browse files
committed
Fixed #9745 (dxGetTextWidth returns wrong width of text)
1 parent 3356dc3 commit 31b20b4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Client/core/Graphics/CGraphics.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ float CGraphics::GetDXTextExtent ( const char * szText, float fScale, LPD3DXFONT
648648
if (bColorCoded)
649649
RemoveColorCodesInPlaceW(strText);
650650

651-
// DT_CALCRECT does not take space characters at the end of a line
651+
// DT_CALCRECT may not take space characters at the end of a line
652652
// into consideration for the rect size.
653653
// Count the amount of space characters at the end
654654
int iSpaceCount = 0;
@@ -669,6 +669,8 @@ float CGraphics::GetDXTextExtent ( const char * szText, float fScale, LPD3DXFONT
669669
SIZE size;
670670
GetTextExtentPoint32W( dc, L" ", 1, &size );
671671
iAdditionalPixels = iSpaceCount * size.cx;
672+
// Remove trailing spaces from the text
673+
strText = strText.Left(strText.length() - iSpaceCount);
672674
}
673675

674676
// Compute the size of the text itself

0 commit comments

Comments
 (0)