From 3b76e590d4c01c4d874acb59753eaf6cce67d021 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Nov 2017 16:26:12 +0100 Subject: [PATCH] Return descent from Cairo GetTextExtent() even for empty strings This method still needs to return the correct descent in this case. Fixes MeasuringTextTestCase::LeadingAndDescent() unit test failure with GTK+ 3. --- src/generic/graphicc.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 12e858d9c9..9b526da9f1 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -2644,7 +2644,10 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub if ( externalLeading ) *externalLeading = 0; - if ( str.empty()) + // We can skip computing the string width and height if it is empty, but + // not its descent and/or external leading, which still needs to be + // returned even for an empty string. + if ( str.empty() && !descent && !externalLeading ) return; if ( ((wxCairoFontData*)m_font.GetRefData())->Apply((wxCairoContext*)this) )