From 6e9bc98d0bfc8c6357d7fdf586f7295070a371da Mon Sep 17 00:00:00 2001 From: Brian Ferguson Date: Sat, 13 Jul 2013 10:16:35 -0600 Subject: [PATCH] GDI+: Add trailing whitespace when measuring text (similar to 32fc794) --- Common/Gfx/CanvasGDIP.cpp | 2 +- Common/Gfx/TextFormatGDIP.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Common/Gfx/CanvasGDIP.cpp b/Common/Gfx/CanvasGDIP.cpp index 48f2c149..a64ecce8 100644 --- a/Common/Gfx/CanvasGDIP.cpp +++ b/Common/Gfx/CanvasGDIP.cpp @@ -181,7 +181,7 @@ bool CanvasGDIP::MeasureTextLinesW(const WCHAR* str, UINT strLen, const TextForm stringFormat.SetTrimming(Gdiplus::StringTrimmingNone); const INT stringFormatFlags = stringFormat.GetFormatFlags(); - stringFormat.SetFormatFlags(Gdiplus::StringFormatFlagsNoClip); + stringFormat.SetFormatFlags(Gdiplus::StringFormatFlagsMeasureTrailingSpaces | Gdiplus::StringFormatFlagsNoClip); INT linesFilled = 0; const Gdiplus::Status status = m_Graphics->MeasureString( diff --git a/Common/Gfx/TextFormatGDIP.cpp b/Common/Gfx/TextFormatGDIP.cpp index ecb0edb8..e8adce0c 100644 --- a/Common/Gfx/TextFormatGDIP.cpp +++ b/Common/Gfx/TextFormatGDIP.cpp @@ -101,12 +101,13 @@ void TextFormatGDIP::SetTrimming(bool trim) if (trim) { m_StringFormat.SetTrimming(Gdiplus::StringTrimmingEllipsisCharacter); - m_StringFormat.SetFormatFlags(0x0); + m_StringFormat.SetFormatFlags(Gdiplus::StringFormatFlagsMeasureTrailingSpaces); } else { m_StringFormat.SetTrimming(Gdiplus::StringTrimmingNone); - m_StringFormat.SetFormatFlags(Gdiplus::StringFormatFlagsNoClip | Gdiplus::StringFormatFlagsNoWrap); + m_StringFormat.SetFormatFlags(Gdiplus::StringFormatFlagsMeasureTrailingSpaces | + Gdiplus::StringFormatFlagsNoClip | Gdiplus::StringFormatFlagsNoWrap); } }