diff --git a/include/wx/private/textmeasure.h b/include/wx/private/textmeasure.h index db96dcd38f..3671a87180 100644 --- a/include/wx/private/textmeasure.h +++ b/include/wx/private/textmeasure.h @@ -128,6 +128,10 @@ protected: wxCoord *descent = NULL, wxCoord *externalLeading = NULL); + // Get line height: used when the line is empty because CallGetTextExtent() + // would just return (0, 0) in this case. + int GetEmptyLineHeight(); + // Return a valid font: if one was given to us in the ctor, use this one, // otherwise use the current font of the associated wxDC or wxWindow. wxFont GetFont() const; diff --git a/src/common/textmeasurecmn.cpp b/src/common/textmeasurecmn.cpp index 16448d2664..b54bebeb6a 100644 --- a/src/common/textmeasurecmn.cpp +++ b/src/common/textmeasurecmn.cpp @@ -100,6 +100,13 @@ void wxTextMeasureBase::GetTextExtent(const wxString& string, CallGetTextExtent(string, width, height, descent, externalLeading); } +int wxTextMeasureBase::GetEmptyLineHeight() +{ + int dummy, height; + CallGetTextExtent(wxS("W"), &dummy, &height); + return height; +} + void wxTextMeasureBase::GetMultiLineTextExtent(const wxString& text, wxCoord *width, wxCoord *height, @@ -136,12 +143,9 @@ void wxTextMeasureBase::GetMultiLineTextExtent(const wxString& text, if ( !heightLineDefault ) heightLineDefault = heightLine; + // and if we hadn't had any previous one neither, compute it now if ( !heightLineDefault ) - { - // but we don't know it yet - choose something reasonable - int dummy; - CallGetTextExtent(wxS("W"), &dummy, &heightLineDefault); - } + heightLineDefault = GetEmptyLineHeight(); heightTextTotal += heightLineDefault; }