aboutsummaryrefslogtreecommitdiffhomepage
path: root/qt/ScintillaEditBase/PlatQt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt/ScintillaEditBase/PlatQt.cpp')
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index 713f4c46f..87496a191 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -10,6 +10,7 @@
#include "PlatQt.h"
#include "Scintilla.h"
+#include "UniConversion.h"
#include "DBCS.h"
#include "FontQuality.h"
@@ -438,19 +439,6 @@ void SurfaceImpl::SetClip(PRectangle rc)
GetPainter()->setClipRect(QRectFFromPRect(rc));
}
-static size_t utf8LengthFromLead(unsigned char uch)
-{
- if (uch >= (0x80 + 0x40 + 0x20 + 0x10)) {
- return 4;
- } else if (uch >= (0x80 + 0x40 + 0x20)) {
- return 3;
- } else if (uch >= (0x80)) {
- return 2;
- } else {
- return 1;
- }
-}
-
void SurfaceImpl::MeasureWidths(Font &font,
const char *s,
int len,
@@ -470,10 +458,10 @@ void SurfaceImpl::MeasureWidths(Font &font,
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
int i=0;
while (ui<fit) {
- size_t lenChar = utf8LengthFromLead(us[i]);
- int codeUnits = (lenChar < 4) ? 1 : 2;
+ const unsigned int byteCount = UTF8BytesOfLead[us[i]];
+ const int codeUnits = UTF16LengthFromUTF8ByteCount(byteCount);
qreal xPosition = tl.cursorToX(ui+codeUnits);
- for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
+ for (unsigned int bytePos=0; (bytePos<byteCount) && (i<len); bytePos++) {
positions[i++] = xPosition;
}
ui += codeUnits;