- int totalWidth = 0;
-
- // reset the cache if font or horizontal scale have changed
- if ( !s_fontWidthCache.m_widths ||
- !wxIsSameDouble(s_fontWidthCache.m_scaleX, scaleX) ||
- (s_fontWidthCache.m_font != *m_font) )
- {
- s_fontWidthCache.Reset();
- s_fontWidthCache.m_font = *m_font;
- s_fontWidthCache.m_scaleX = scaleX;
- }
-
- // Calculate the position of each character based on the widths of
- // the previous characters. This is inexact for not fixed fonts.
- int n = 0;
- for ( wxString::const_iterator it = text.begin();
- it != text.end();
- ++it )
- {
- const wxChar c = *it;
- unsigned int c_int = (unsigned int)c;
-
- int w;
- if ((c_int < FWC_SIZE) && (s_fontWidthCache.m_widths[c_int] != 0))
- {
- w = s_fontWidthCache.m_widths[c_int];
- }
- else
- {
- DoGetTextExtent(c, &w, NULL);
- if (c_int < FWC_SIZE)
- s_fontWidthCache.m_widths[c_int] = w;
- }
-
- totalWidth += w;
- widths[n++] = totalWidth;
- }
-
- return true;