From 4e71b4cf2f113f5f5a8cd488b3b8e433006f5a60 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Sat, 19 Aug 2017 08:51:40 +0200 Subject: [PATCH 1/4] + fix: manually edited settings (SciDirectWriteTech, SciFontQuality) should be placed in settings section [Settings2]. --- distrib/Notepad3.ini | Bin 1150 -> 1150 bytes src/Notepad3.c | 13 ++++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/distrib/Notepad3.ini b/distrib/Notepad3.ini index 7349d7bbaf83f6aff29a8379c0a07b9abd943771..3a5f01638a1c502fd1f3a985da4e89f106cfccfc 100644 GIT binary patch delta 21 dcmeyz@sDG}Hpb0dOi_%Jw=srnPGOc}1OQ-%2VnpJ delta 21 dcmeyz@sDG}Hpa;U%pse%F-9?NPGOc}1OQ><2WS8Q diff --git a/src/Notepad3.c b/src/Notepad3.c index 6833e0bc4..bcdadce3c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -5883,12 +5883,6 @@ void LoadSettings() xFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosX",0); yFindReplaceDlg = IniSectionGetInt(pIniSection,L"FindReplaceDlgPosY",0); - iSciDirectWriteTech = IniSectionGetInt(pIniSection,L"SciDirectWriteTech",-1); - iSciDirectWriteTech = max(min(iSciDirectWriteTech,3),-1); - - iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1); - iSciFontQuality = max(min(iSciFontQuality,3),-1); - LoadIniSection(L"Settings2",pIniSection,cchIniSection); @@ -5909,6 +5903,12 @@ void LoadSettings() dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000); dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000); + iSciDirectWriteTech = IniSectionGetInt(pIniSection,L"SciDirectWriteTech",-1); + iSciDirectWriteTech = max(min(iSciDirectWriteTech,3),-1); + + iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1); + iSciFontQuality = max(min(iSciFontQuality,3),-1); + WCHAR buffer[MIDSZ_BUFFER]; const WCHAR defextwsc[] = L".,;:|/-+$%&<>(){}[]=?#'*"; IniSectionGetString(pIniSection, L"ExtendedWhiteSpaceChars", defextwsc, buffer, COUNTOF(buffer)); @@ -6103,7 +6103,6 @@ void SaveSettings(BOOL bSaveSettingsNow) { IniSectionSetInt(pIniSection, L"FavoritesDlgSizeY", cyFavoritesDlg); IniSectionSetInt(pIniSection, L"FindReplaceDlgPosX", xFindReplaceDlg); IniSectionSetInt(pIniSection, L"FindReplaceDlgPosY", yFindReplaceDlg); - IniSectionSetInt(pIniSection, L"SciFontQuality", iSciFontQuality); SaveIniSection(L"Settings", pIniSection); LocalFree(pIniSection); From d289084fd448c63a91fa3beedf2513dc547069cf Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 21 Aug 2017 11:03:46 +0200 Subject: [PATCH 2/4] + extended default "space char set" for "Accelerated Word Navigation" + to avoid unexpected "accelerated word navigation" behavior, space-char extension is restricted to 7-bit ASCII char set (ignoring specified non-7-bit-ASCII chars). --- src/Notepad3.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index bcdadce3c..30f55fa6a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -5909,12 +5909,16 @@ void LoadSettings() iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1); iSciFontQuality = max(min(iSciFontQuality,3),-1); - WCHAR buffer[MIDSZ_BUFFER]; - const WCHAR defextwsc[] = L".,;:|/-+$%&<>(){}[]=?#'*"; + WCHAR buffer[MIDSZ_BUFFER] = { L'\0' }; + const WCHAR defextwsc[] = L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"; // underscore counted as part of word IniSectionGetString(pIniSection, L"ExtendedWhiteSpaceChars", defextwsc, buffer, COUNTOF(buffer)); if (!lstrlen(buffer)) lstrcpyn(buffer, defextwsc, COUNTOF(buffer)); WCHAR2MBCS(CP_ACP,buffer,chExtendedWhiteSpaceChars,COUNTOF(chExtendedWhiteSpaceChars)); - + // clear non-7-bit-ASCII chars + for (size_t i = 0; i < strlen(chExtendedWhiteSpaceChars); i++) { + if (chExtendedWhiteSpaceChars[i] & ~0x7F) + chExtendedWhiteSpaceChars[i] = ' '; // space + } LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection); From 8b54c33aa2c726b9128561ce41e193b67cbde9bd Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 22 Aug 2017 01:38:58 +0200 Subject: [PATCH 3/4] +fix: settings SciFontQuality have been overwritten by Scheme configuration - adapted (Fonts: Calibri,Cambria,Candara,Consolas,Constantia,Corbel,Segoe UI are using 'cleartype smoothing' (SC_EFF_QUALITY_LCD_OPTIMIZED) by default, if not configured in Schema definition for Lexer) --- src/Notepad3.c | 17 +++++++---------- src/SciCall.h | 8 -------- src/Styles.c | 8 ++++---- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index 30f55fa6a..92bc73c16 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -179,21 +179,20 @@ int iSciDirectWriteTech; int iSciFontQuality; int iHighDpiToolBar; -const int DirectWriteTechnology[] = { - SC_TECHNOLOGY_DEFAULT +const int DirectWriteTechnology[4] = { + SC_TECHNOLOGY_DEFAULT , SC_TECHNOLOGY_DIRECTWRITE , SC_TECHNOLOGY_DIRECTWRITERETAIN , SC_TECHNOLOGY_DIRECTWRITEDC }; -const int FontQuality[] = { - SC_EFF_QUALITY_DEFAULT +const int FontQuality[4] = { + SC_EFF_QUALITY_DEFAULT , SC_EFF_QUALITY_NON_ANTIALIASED , SC_EFF_QUALITY_ANTIALIASED , SC_EFF_QUALITY_LCD_OPTIMIZED }; - typedef struct _wi { int x; @@ -698,8 +697,6 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpCmdLine,int n if (IsVista()) { if (iSciDirectWriteTech >= 0) SciCall_SetTechnology(DirectWriteTechnology[iSciDirectWriteTech]); - if (iSciFontQuality >= 0) - SciCall_SetFontQuality(FontQuality[iSciFontQuality]); } if (bAccelWordNavigation) @@ -5906,8 +5903,8 @@ void LoadSettings() iSciDirectWriteTech = IniSectionGetInt(pIniSection,L"SciDirectWriteTech",-1); iSciDirectWriteTech = max(min(iSciDirectWriteTech,3),-1); - iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1); - iSciFontQuality = max(min(iSciFontQuality,3),-1); + iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",0); + iSciFontQuality = max(min(iSciFontQuality,3),0); WCHAR buffer[MIDSZ_BUFFER] = { L'\0' }; const WCHAR defextwsc[] = L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~"; // underscore counted as part of word @@ -5971,7 +5968,7 @@ void LoadSettings() WCHAR tchSciFontQuality[32]; wsprintf(tchSciFontQuality,L"%ix%i SciFontQuality",ResX,ResY); iSciFontQuality = IniSectionGetInt(pIniSection,tchSciFontQuality,iSciFontQuality); - iSciFontQuality = max(min(iSciFontQuality,3),-1); + iSciFontQuality = max(min(iSciFontQuality,3),0); LocalFree(pIniSection); diff --git a/src/SciCall.h b/src/SciCall.h index aaa0d039f..aa2793ce3 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -156,11 +156,3 @@ DeclareSciCallV2(SetProperty, SETPROPERTY, const char *, key, const char *, valu // // DeclareSciCallV1(SetTechnology, SETTECHNOLOGY, int, technology); - - -//============================================================================= -// -// SetFontQuality -// -// -DeclareSciCallV1(SetFontQuality, SETFONTQUALITY, int, quality); diff --git a/src/Styles.c b/src/Styles.c index db579b69d..3de176471 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -35,6 +35,8 @@ extern HINSTANCE g_hInstance; extern int iEncoding; +extern int iSciFontQuality; +extern const int FontQuality[4]; #define MULTI_STYLE(a,b,c,d) ((a)|(b<<8)|(c<<16)|(d<<24)) @@ -4272,7 +4274,7 @@ void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) // void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { - WPARAM wQuality = SC_EFF_QUALITY_DEFAULT; + WPARAM wQuality = FontQuality[iSciFontQuality];; WCHAR tch[32]; if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) { @@ -4282,7 +4284,7 @@ void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { wQuality = SC_EFF_QUALITY_ANTIALIASED; else if (lstrcmpi(tch,L"cleartype") == 0) wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; - else + else if (lstrcmpi(tch,L"default") == 0) wQuality = SC_EFF_QUALITY_DEFAULT; } else { @@ -4296,8 +4298,6 @@ void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { lstrcmpi(tch,L"Segoe UI") == 0) wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; } - else - wQuality = SC_EFF_QUALITY_DEFAULT; } SendMessage(hwnd,SCI_SETFONTQUALITY,wQuality,0); } From 9e64559c251c46796376ef0e237b1b117c115f4e Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Tue, 22 Aug 2017 01:56:17 +0200 Subject: [PATCH 4/4] + add font "Source Code Pro" to list of special fonts for cleartype smoothing --- src/Styles.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Styles.c b/src/Styles.c index 3de176471..d9d742eda 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -4274,20 +4274,20 @@ void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle) // void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { - WPARAM wQuality = FontQuality[iSciFontQuality];; - WCHAR tch[32]; + WPARAM wQuality = (WPARAM)FontQuality[iSciFontQuality];; + WCHAR tch[64] = { L'\0' }; if (Style_StrGetFontQuality(lpszStyle,tch,COUNTOF(tch))) { - if (lstrcmpi(tch,L"none") == 0) + if (lstrcmpi(tch,L"default") == 0) + wQuality = SC_EFF_QUALITY_DEFAULT; + else if (lstrcmpi(tch,L"none") == 0) wQuality = SC_EFF_QUALITY_NON_ANTIALIASED; else if (lstrcmpi(tch,L"standard") == 0) wQuality = SC_EFF_QUALITY_ANTIALIASED; else if (lstrcmpi(tch,L"cleartype") == 0) wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; - else if (lstrcmpi(tch,L"default") == 0) - wQuality = SC_EFF_QUALITY_DEFAULT; } - else { + else { // undefined, use general settings, except for special fonts if (Style_StrGetFont(lpszStyle,tch,COUNTOF(tch))) { if (lstrcmpi(tch,L"Calibri") == 0 || lstrcmpi(tch,L"Cambria") == 0 || @@ -4295,7 +4295,8 @@ void Style_SetFontQuality(HWND hwnd,LPCWSTR lpszStyle) { lstrcmpi(tch,L"Consolas") == 0 || lstrcmpi(tch,L"Constantia") == 0 || lstrcmpi(tch,L"Corbel") == 0 || - lstrcmpi(tch,L"Segoe UI") == 0) + lstrcmpi(tch,L"Segoe UI") == 0 || + lstrcmpi(tch,L"Source Code Pro") == 0) wQuality = SC_EFF_QUALITY_LCD_OPTIMIZED; } }