aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r--win32/PlatWin.cxx19
1 files changed, 8 insertions, 11 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 9e89e2f84..79970a969 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -951,12 +951,14 @@ void SurfaceGDI::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
return;
}
// Map the widths given for UTF-16 characters back onto the UTF-8 input string
+ const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
for (int ui = 0; ui < fit; ui++) {
- const unsigned int lenChar = UTF8BytesOfLead[static_cast<unsigned char>(s[i])];
- if (lenChar == 4) { // Non-BMP
+ const unsigned char uch = us[i];
+ const unsigned int byteCount = UTF8BytesOfLead[uch];
+ if (byteCount == 4) { // Non-BMP
ui++;
}
- for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
+ for (unsigned int bytePos=0; (bytePos<byteCount) && (i<len); bytePos++) {
positions[i++] = static_cast<XYPOSITION>(poses.buffer[ui]);
}
}
@@ -1623,16 +1625,11 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
int i=0;
while (ui<tbuf.tlen) {
const unsigned char uch = us[i];
- unsigned int lenChar = 1;
- if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) {
- lenChar = 4;
+ const unsigned int byteCount = UTF8BytesOfLead[uch];
+ if (byteCount == 4) { // Non-BMP
ui++;
- } else if (uch >= (0x80 + 0x40 + 0x20)) {
- lenChar = 3;
- } else if (uch >= (0x80)) {
- lenChar = 2;
}
- for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
+ for (unsigned int bytePos=0; (bytePos<byteCount) && (i<len); bytePos++) {
positions[i++] = poses.buffer[ui];
}
ui++;