From 4d36ecc2295117c77750e0c1df71cb65362549c5 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Fri, 12 Apr 2019 08:22:21 +1000 Subject: Backport: Bug [#2093]. Improve efficiency with single byte character sets. Backport of changeset 7424:0d4b29e058f7. --- src/DBCS.h | 8 ++++++++ win32/PlatWin.cxx | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/DBCS.h b/src/DBCS.h index ff3f9f22f..58659ee3e 100644 --- a/src/DBCS.h +++ b/src/DBCS.h @@ -10,6 +10,14 @@ namespace Scintilla { +constexpr bool IsDBCSCodePage(int codePage) noexcept { + return codePage == 932 + || codePage == 936 + || codePage == 949 + || codePage == 950 + || codePage == 1361; +} + bool DBCSIsLeadByte(int codePage, char ch) noexcept; } diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 4ccc40f14..2b807198a 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1177,7 +1177,7 @@ void SurfaceD2D::SetFont(Font &font_) { yDescent = pfm->yDescent; yInternalLeading = pfm->yInternalLeading; codePageText = codePage; - if (pfm->characterSet) { + if (!unicodeMode && pfm->characterSet) { codePageText = Scintilla::CodePageFromCharSet(pfm->characterSet, codePage); } if (pRenderTarget) { @@ -1613,7 +1613,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION * while (i