X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1bce253a23047c6153e130d02e776d3d34b05793..72625b36b6fdaea839a5132e8f5d52dea7155bec:/src/msw/textmeasure.cpp

diff --git a/src/msw/textmeasure.cpp b/src/msw/textmeasure.cpp
index e25eeac859..232053d7f8 100644
--- a/src/msw/textmeasure.cpp
+++ b/src/msw/textmeasure.cpp
@@ -69,8 +69,12 @@ void wxTextMeasure::BeginMeasuring()
         m_hdc = ::GetDC(GetHwndOf(m_win));
     }
 
-    if ( m_font )
-        m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(*m_font));
+    // We need to set the font if it's explicitly specified, of course, but
+    // also if we're associated with a window because the window HDC created
+    // above has the default font selected into it and not the font of the
+    // window.
+    if ( m_font || m_win )
+        m_hfontOld = (HFONT)::SelectObject(m_hdc, GetHfontOf(GetFont()));
 }
 
 void wxTextMeasure::EndMeasuring()
@@ -146,8 +150,11 @@ void wxTextMeasure::DoGetTextExtent(const wxString& string,
 
 bool wxTextMeasure::DoGetPartialTextExtents(const wxString& text,
                                             wxArrayInt& widths,
-                                            double WXUNUSED(scaleX))
+                                            double scaleX)
 {
+    if ( !m_hdc )
+        return wxTextMeasureBase::DoGetPartialTextExtents(text, widths, scaleX);
+
     static int maxLenText = -1;
     static int maxWidth = -1;