From 35f2e1591ef8c1e56e7274b83dd55bc93785747a Mon Sep 17 00:00:00 2001 From: Brian Ferguson Date: Tue, 8 Oct 2013 20:10:57 +0300 Subject: [PATCH] Gfx: Fix non-zero height for empty strings with D2D http://rainmeter.net/forum/viewtopic.php?p=92801 --- Common/Gfx/CanvasD2D.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Common/Gfx/CanvasD2D.cpp b/Common/Gfx/CanvasD2D.cpp index 86c7f6a0..1ab02e86 100644 --- a/Common/Gfx/CanvasD2D.cpp +++ b/Common/Gfx/CanvasD2D.cpp @@ -404,9 +404,12 @@ bool CanvasD2D::MeasureTextLinesW(const WCHAR* str, UINT strLen, const TextForma rect.Height = metrics.height; lines = metrics.lineCount; - // GDI+ draws multi-line text even though the last line may be clipped slightly at the bottom. - // This is a workaround to emulate that behaviour. - rect.Height += 1.0f; + if (rect.Height > 0.0f) + { + // GDI+ draws multi-line text even though the last line may be clipped slightly at the + // bottom. This is a workaround to emulate that behaviour. + rect.Height += 1.0f; + } return true; }