diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index ac67883705..b486d4f75f 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -2333,24 +2333,14 @@ void wxCairoContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& while (i++ < len) widths.Add(PANGO_PIXELS(w)); #else - const wxCharBuffer data = text.utf8_str(); - for (size_t i = 0; i < data.length(); i++) + for (size_t i = 0; i < text.Length(); i++) { + const wxCharBuffer data = text.SubString(0, i).utf8_str(); + cairo_text_extents_t te; - char ch[2]; + cairo_text_extents(m_context, (const char*)data, &te); - ch[0] = data[i]; - ch[1] = '\0'; - cairo_text_extents(m_context, ch, &te); - - double w; - // Last character is interpreted in a different way. - if( i == data.length()-1 ) - w = te.width; - else - w = te.x_advance; - - widths.push_back(w); + widths.push_back(te.width); } #endif }