diff options
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 16 | 
1 files changed, 11 insertions, 5 deletions
| diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index be6c2305a..70f0faa1b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -497,7 +497,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const ch  	RECT rcw = RectFromPRectangle(rc);  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN]; -		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)); +		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)-1);  		tbuf[tlen] = L'\0';  		::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL);  	} else { @@ -513,7 +513,7 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const c  	RECT rcw = RectFromPRectangle(rc);  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN]; -		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)); +		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)-1);  		tbuf[tlen] = L'\0';  		::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL);  	} else { @@ -526,7 +526,7 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {  	SIZE sz={0,0};  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN]; -		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)); +		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)-1);  		tbuf[tlen] = L'\0';  		::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz);  	} else { @@ -541,7 +541,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  	int fit = 0;  	if (unicodeMode) {  		wchar_t tbuf[MAX_US_LEN]; -		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)); +		int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)-1);  		tbuf[tlen] = L'\0';  		int poses[MAX_US_LEN];  		fit = tlen; @@ -558,7 +558,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  		int ui=0;  		const unsigned char *us = reinterpret_cast<const unsigned char *>(s);  		int i=0; -		while (i<len) { +		while (i<fit) {  			unsigned char uch = us[i];  			positions[i++] = poses[ui];  			if (uch >= 0x80) { @@ -571,6 +571,12 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  			}  			ui++;  		} +		int lastPos = 0; +		if (i > 0) +			lastPos = positions[i-1]; +		while (i<len) { +			positions[i++] = lastPos; +		}  	} else {  		if (!::GetTextExtentExPoint(hdc, s, len, 30000, &fit, positions, &sz)) {  			// Eeek - a NULL DC or other foolishness could cause this. | 
