From 0a821b60e255046bfb75ef7caea7730c5411cfe5 Mon Sep 17 00:00:00 2001 From: Udo Hoffmann Date: Wed, 27 May 2020 14:17:23 +0200 Subject: [PATCH] Add an option to improve rendering special Unicode characters ... by using Scintilla's DirectWrite technology. It allows ligature support if the font needed (for exemple "Fira Code") is installed. Fix #2287, close #8326 Fix #442, fix #675, fix #813, fix #870, fix #1621, fix #3458, fix #4056, fix #4086, fix #4490, fix #8305 --- PowerEditor/src/Parameters.cpp | 5 +++++ PowerEditor/src/Parameters.h | 2 ++ PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp | 5 +++++ PowerEditor/src/WinControls/Preference/preference.rc | 5 +++-- PowerEditor/src/WinControls/Preference/preferenceDlg.cpp | 7 +++++++ PowerEditor/src/WinControls/Preference/preference_rc.h | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 0512e151..427cf434 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5141,6 +5141,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (optNameMonoFont) _nppGUI._monospacedFontFindDlg = (lstrcmp(optNameMonoFont, TEXT("yes")) == 0); + const TCHAR * optNameWriteTechnologyEngine = element->Attribute(TEXT("writeTechnologyEngine")); + if (optNameWriteTechnologyEngine) + _nppGUI._writeTechnologyEngine = (lstrcmp(optNameWriteTechnologyEngine, TEXT("1")) == 0) ? directWriteTechnology : defaultTechnology; + const TCHAR * optStopFillingFindField = element->Attribute(TEXT("stopFillingFindField")); if (optStopFillingFindField) _nppGUI._stopFillingFindField = (lstrcmp(optStopFillingFindField, TEXT("yes")) == 0); @@ -5919,6 +5923,7 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), _nppGUI._fileSwitcherWithoutExtColumn ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("backSlashIsEscapeCharacterForSql"), _nppGUI._backSlashIsEscapeCharacterForSql ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("monospacedFontFindDlg"), _nppGUI._monospacedFontFindDlg ? TEXT("yes") : TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("writeTechnologyEngine"), _nppGUI._writeTechnologyEngine); GUIConfigElement->SetAttribute(TEXT("stopFillingFindField"), _nppGUI._stopFillingFindField ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("newStyleSaveDlg"), _nppGUI._useNewStyleSaveDlg ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("isFolderDroppedOpenFiles"), _nppGUI._isFolderDroppedOpenFiles ? TEXT("yes") : TEXT("no")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index c40add46..49089441 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -91,6 +91,7 @@ enum ChangeDetect { cdDisabled = 0x0, cdEnabledOld = 0x01, cdEnabledNew = 0x02, enum BackupFeature {bak_none = 0, bak_simple = 1, bak_verbose = 2}; enum OpenSaveDirSetting {dir_followCurrent = 0, dir_last = 1, dir_userDef = 2}; enum MultiInstSetting {monoInst = 0, multiInstOnSession = 1, multiInst = 2}; +enum writeTechnologyEngine {defaultTechnology = 0, directWriteTechnology = 1}; const int LANG_INDEX_INSTR = 0; const int LANG_INDEX_INSTR2 = 1; @@ -835,6 +836,7 @@ struct NppGUI final bool _backSlashIsEscapeCharacterForSql = true; bool _stopFillingFindField = false; bool _monospacedFontFindDlg = false; + writeTechnologyEngine _writeTechnologyEngine = defaultTechnology; bool _isWordCharDefault = true; std::string _customWordChars; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 4d8ed439..e7f0d518 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -331,6 +331,11 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) execute(SCI_INDICSETHOVERSTYLE, URL_INDIC, INDIC_FULLBOX); + if ((NppParameters::getInstance()).getNppGUI()._writeTechnologyEngine == directWriteTechnology) + execute(SCI_SETTECHNOLOGY, SC_TECHNOLOGY_DIRECTWRITE); + // If useDirectWrite is turned off, leave the technology setting untouched, + // so that existing plugins using SCI_SETTECHNOLOGY behave like before + _codepage = ::GetACP(); ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, reinterpret_cast(this)); diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index af852cb4..626b0e3e 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -33,14 +33,14 @@ #define IDC_STATIC -1 #endif -IDD_PREFERENCE_BOX DIALOGEX 0, 0, 560, 220 +IDD_PREFERENCE_BOX DIALOGEX 0, 0, 560, 235 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Preferences" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN LISTBOX IDC_LIST_DLGTITLE,10,10,80,185,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - PUSHBUTTON "Close",IDC_BUTTON_CLOSE,255,200,45,14 + PUSHBUTTON "Close",IDC_BUTTON_CLOSE,255,215,45,14 END IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 455, 185 @@ -126,6 +126,7 @@ BEGIN CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,143,217,10 CONTROL "Don't fill find field in Find dialog with selected word", IDC_CHECK_STOPFILLINGFINDFIELD, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,158,217,10 CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)",IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,173,325,10 + CONTROL "Use DirectWrite (May improve rendering special characters, need to restart Notepad++)",IDC_CHECK_DIRECTWRITE_ENABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,188,377,10 CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10 CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10 COMBOBOX IDC_COMBO_FILEUPDATECHOICE,267, 60,140,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index e6727204..5d3954d5 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -903,6 +903,7 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFindDlg, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_DIRECTWRITE_ENABLE, BM_SETCHECK, nppGUI._writeTechnologyEngine == directWriteTechnology, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKER, BM_SETCHECK, nppGUI._isDocPeekOnTab ? BST_CHECKED : BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCPEEKONMAP, BM_SETCHECK, nppGUI._isDocPeekOnMap ? BST_CHECKED : BST_UNCHECKED, 0); @@ -1071,6 +1072,12 @@ INT_PTR CALLBACK SettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return TRUE; } + case IDC_CHECK_DIRECTWRITE_ENABLE: + { + nppGUI._writeTechnologyEngine = isCheckedOrNot(IDC_CHECK_DIRECTWRITE_ENABLE) ? directWriteTechnology : defaultTechnology; + return TRUE; + } + case IDC_CHECK_ENABLEDOCPEEKER: { nppGUI._isDocPeekOnTab = isCheckedOrNot(IDC_CHECK_ENABLEDOCPEEKER); diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index f2b60154..86a85803 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -209,6 +209,7 @@ #define IDC_CHECK_ENABLEDOCPEEKONMAP (IDD_PREFERENCE_SETTING_BOX + 46) #define IDC_COMBO_FILEUPDATECHOICE (IDD_PREFERENCE_SETTING_BOX + 47) #define IDC_CHECK_STOPFILLINGFINDFIELD (IDD_PREFERENCE_SETTING_BOX + 48) + #define IDC_CHECK_DIRECTWRITE_ENABLE (IDD_PREFERENCE_SETTING_BOX + 49) #define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400) #define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)