Fixed calculating widths in wxCairoContext::GetPartialTextExtents (wxMSW).
Widths from the beginning of text to the corresponding character should be calculated instead of widths of individual characters.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user