Fix SurfaceImpl::MeasureWidths on OS X to do whole string measurments

rather than a running total of indiviual widths.  This is to get
around "fractional pixel" widths when using AA.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-01-17 23:10:00 +00:00
parent ec73fc1643
commit 4e51e03f4f

View File

@@ -430,9 +430,11 @@ int SurfaceImpl::WidthText(Font &font, const char *s, int len) {
void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positions) {
wxString str = stc2wx(s, len);
SetFont(font);
#ifndef __WXMAC__
// Calculate the position of each character based on the widths of
// the previous characters
int* tpos = new int[len];
@@ -444,9 +446,26 @@ void SurfaceImpl::MeasureWidths(Font &font, const char *s, int len, int *positio
totalWidth += w;
tpos[i] = totalWidth;
}
#else
// Instead of a running total, remeasure from the begining of the
// text for each character's position. This is because with AA fonts
// on OS X widths can be fractions of pixels wide when more than one
// are drawn together, so the sum of all character widths is not necessariy
// (and probably not) the same as the whole string width.
int* tpos = new int[len];
size_t i;
for (i=0; i<str.Length(); i++) {
int w, h;
hdc->GetTextExtent(str.Left(i+1), &w, &h);
tpos[i] = w;
}
#endif
#if wxUSE_UNICODE
// Map the widths for UCS-2 characters back to the UTF-8 input string
// NOTE: I don't think this is right for when sizeof(wxChar) > 2, ie wxGTK2
// so figure it out and fix it!
i = 0;
size_t ui = 0;
while (i < len) {