From aa4c4a6dfc4b527e513784a903e61403b0d99439 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 10 Aug 2013 13:58:54 +0300 Subject: [PATCH] Gfx: Make AccurateText=1 more consistent with GDI+ for D2D when a newline character is the last character of the text --- Common/Gfx/TextFormatD2D.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Common/Gfx/TextFormatD2D.cpp b/Common/Gfx/TextFormatD2D.cpp index 015138a5..224b084b 100644 --- a/Common/Gfx/TextFormatD2D.cpp +++ b/Common/Gfx/TextFormatD2D.cpp @@ -249,6 +249,15 @@ DWRITE_TEXT_METRICS TextFormatD2D::GetMetrics( metrics.height += m_LineGap; } } + else + { + // GDI+ compatibility: With accurate metrics, the line gap needs to be subtracted + // from the overall height if the string does not contain newlines. + if (!strippedLastNewLine && wmemchr(str, L'\n', strLen) == nullptr) + { + metrics.height -= m_LineGap; + } + } } else {