From e02364cbadcb95a1704e3f5e564250ddaa422b4e Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Sun, 6 Jul 2014 21:45:40 +0800 Subject: [PATCH] Applied unicodefont.patch Signed-off-by: Sup Yut Sum --- ext/scintilla/win32/PlatWin.cxx | 20 ++++++++++++-------- ext/scintilla/win32/ScintillaWin.cxx | 11 ++++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ext/scintilla/win32/PlatWin.cxx b/ext/scintilla/win32/PlatWin.cxx index 225450669..aa7be802d 100644 --- a/ext/scintilla/win32/PlatWin.cxx +++ b/ext/scintilla/win32/PlatWin.cxx @@ -274,15 +274,15 @@ static D2D1_TEXT_ANTIALIAS_MODE DWriteMapFontQuality(int extraFontFlag) { } #endif -static void SetLogFont(LOGFONTA &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) { - lf = LOGFONTA(); +static void SetLogFont(LOGFONTW &lf, const char *faceName, int characterSet, float size, int weight, bool italic, int extraFontFlag) { + lf = LOGFONTW(); // The negative is to allow for leading lf.lfHeight = -(abs(static_cast(size + 0.5))); lf.lfWeight = weight; lf.lfItalic = static_cast(italic ? 1 : 0); lf.lfCharSet = static_cast(characterSet); lf.lfQuality = Win32MapFontQuality(extraFontFlag); - StringCopy(lf.lfFaceName, faceName); + UTF16FromUTF8(faceName, strlen(faceName)+1, lf.lfFaceName, LF_FACESIZE); } /** @@ -305,7 +305,7 @@ class FontCached : Font { FontCached *next; int usage; float size; - LOGFONTA lf; + LOGFONTW lf; int technology; int hash; explicit FontCached(const FontParameters &fp); @@ -328,7 +328,7 @@ FontCached::FontCached(const FontParameters &fp) : hash = HashFont(fp); fid = 0; if (technology == SCWIN_TECH_GDI) { - HFONT hfont = ::CreateFontIndirectA(&lf); + HFONT hfont = ::CreateFontIndirectW(&lf); fid = reinterpret_cast(new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet)); } else { #if defined(USE_D2D) @@ -377,14 +377,18 @@ FontCached::FontCached(const FontParameters &fp) : } bool FontCached::SameAs(const FontParameters &fp) { - return + if ( (size == fp.size) && (lf.lfWeight == fp.weight) && (lf.lfItalic == static_cast(fp.italic ? 1 : 0)) && (lf.lfCharSet == fp.characterSet) && (lf.lfQuality == Win32MapFontQuality(fp.extraFontFlag)) && - (technology == fp.technology) && - 0 == strcmp(lf.lfFaceName,fp.faceName); + (technology == fp.technology)) { + wchar_t wszFace[LF_FACESIZE]; + UTF16FromUTF8(fp.faceName, strlen(fp.faceName)+1, wszFace, LF_FACESIZE); + return 0 == wcscmp(lf.lfFaceName,wszFace); + } + return false; } void FontCached::Release() { diff --git a/ext/scintilla/win32/ScintillaWin.cxx b/ext/scintilla/win32/ScintillaWin.cxx index 78584bbcb..394aec1ed 100644 --- a/ext/scintilla/win32/ScintillaWin.cxx +++ b/ext/scintilla/win32/ScintillaWin.cxx @@ -2327,7 +2327,7 @@ void ScintillaWin::ImeStartComposition() { // Since the style creation code has been made platform independent, // The logfont for the IME is recreated here. int styleHere = (pdoc->StyleAt(sel.MainCaret())) & 31; - LOGFONTA lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ""}; + LOGFONTW lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, L""}; int sizeZoomed = vs.styles[styleHere].size + vs.zoomLevel * SC_FONT_SIZE_MULTIPLIER; if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1 sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER; @@ -2342,10 +2342,11 @@ void ScintillaWin::ImeStartComposition() { lf.lfItalic = static_cast(vs.styles[styleHere].italic ? 1 : 0); lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = '\0'; - if (vs.styles[styleHere].fontName) - StringCopy(lf.lfFaceName, vs.styles[styleHere].fontName); - - ::ImmSetCompositionFontA(hIMC, &lf); + if (vs.styles[styleHere].fontName) { + const char* fontName = vs.styles[styleHere].fontName; + UTF16FromUTF8(fontName, strlen(fontName)+1, lf.lfFaceName, LF_FACESIZE); + } + ::ImmSetCompositionFontW(hIMC, &lf); } ::ImmReleaseContext(MainHWND(), hIMC); // Caret is displayed in IME window. So, caret in Scintilla is useless. -- 2.11.4.GIT