From 258549f9317e26ad88408f96324edd9c11baeff0 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 23 Dec 2020 10:31:45 +0100 Subject: [PATCH] + chg: initial start screen resolution independent fixed base font size (->11pt == former FullHD setting) --- src/Config/Config.cpp | 4 ++-- src/Notepad3.c | 1 - src/Styles.c | 22 +++++++++++----------- src/Styles.h | 2 +- src/TypeDefs.h | 4 +++- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 553219855..25c41b97a 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1468,7 +1468,7 @@ void LoadSettings() //int const zoomScale = 100; int const baseZoom = 100; int const prtFontSize = 10; - int const zoomScale = MulDiv(baseZoom, prtFontSize, Globals.InitialFontSize); + int const zoomScale = MulDiv(baseZoom, prtFontSize, float2int(GLOBAL_INITIAL_FONTSIZE)); Defaults.PrintZoom = (Globals.iCfgVersionRead < CFG_VER_0001) ? (zoomScale / 10) : zoomScale; int iPrintZoom = clampi(IniSectionGetInt(IniSecSettings, L"PrintZoom", Defaults.PrintZoom), 0, SC_MAX_ZOOM_LEVEL); if (Globals.iCfgVersionRead < CFG_VER_0001) { @@ -1713,7 +1713,7 @@ void LoadSettings() CloseSettingsFile(bDirtyFlag, true); // keep cached - Style_Init(); // Scintilla Styles + Style_Load(); // Scintilla Styles from .ini ResetIniFileCache(); // clear cache } diff --git a/src/Notepad3.c b/src/Notepad3.c index 3eb93f63a..13e7a826a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -650,7 +650,6 @@ static void _InitGlobals() Globals.bDocHasInconsistentEOLs = false; Globals.idxLightModeTheme = 1; // Default(0), Standard(1) Globals.idxDarkModeTheme = 1; // buildin Standard(1) - Globals.InitialFontSize = (IsFullHD(NULL, -1, -1) < 0) ? 10 : 11; Flags.bHugeFileLoadState = DefaultFlags.bHugeFileLoadState = false; Flags.bDevDebugMode = DefaultFlags.bDevDebugMode = false; diff --git a/src/Styles.c b/src/Styles.c index 11cd823ae..76f59576c 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -406,7 +406,7 @@ bool Style_IsCurLexerStandard() // static float _SetBaseFontSize(float fSize) { - static float fBaseFontSize = 11.0f; + static float fBaseFontSize = GLOBAL_INITIAL_FONTSIZE; if (fSize >= 0.0f) { fBaseFontSize = Round10th(fSize); @@ -420,7 +420,7 @@ static float _SetBaseFontSize(float fSize) // float Style_GetBaseFontSize() { - return _SetBaseFontSize(-1.0); + return _SetBaseFontSize(-1.0); // neg. value indicate getter } //============================================================================= @@ -429,7 +429,7 @@ float Style_GetBaseFontSize() // static float _SetCurrentFontSize(float fSize) { - static float fCurrentFontSize = 11.0f; + static float fCurrentFontSize = GLOBAL_INITIAL_FONTSIZE; if (signbit(fSize) == 0) { float const fSizeR10th = Round10th(fSize); @@ -440,7 +440,7 @@ static float _SetCurrentFontSize(float fSize) float Style_GetCurrentFontSize() { - return _SetCurrentFontSize(-1.0f); + return _SetCurrentFontSize(-1.0f); // neg. value indicate getter } @@ -461,12 +461,12 @@ int Style_RgbAlpha(int rgbFore, int rgbBack, int alpha) //============================================================================= // -// Style_Init() +// Style_Load() // -void Style_Init() +void Style_Load() { - _SetBaseFontSize((float)Globals.InitialFontSize); - _SetCurrentFontSize((float)Globals.InitialFontSize); + _SetBaseFontSize(GLOBAL_INITIAL_FONTSIZE); + _SetCurrentFontSize(GLOBAL_INITIAL_FONTSIZE); for (int i = 0; i < 16; ++i) { g_colorCustom[i] = s_colorDefault[i]; @@ -1136,8 +1136,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) //~Style_SetACPfromCharSet(hwnd); // --- apply/init default style --- - _SetBaseFontSize((float)Globals.InitialFontSize); - _SetCurrentFontSize((float)Globals.InitialFontSize); + _SetBaseFontSize(GLOBAL_INITIAL_FONTSIZE); + _SetCurrentFontSize(GLOBAL_INITIAL_FONTSIZE); const WCHAR* const wchStandardStyleStrg = pCurrentStandard->Styles[STY_DEFAULT].szValue; @@ -3378,7 +3378,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam // is "size:" definition relative ? bool const bRelFontSize = (!StrStr(lpszStyle, L"size:") || StrStr(lpszStyle, L"size:+") || StrStr(lpszStyle, L"size:-")); - float const fBaseFontSize = (bGlobalDefaultStyle ? (float)Globals.InitialFontSize : + float const fBaseFontSize = (bGlobalDefaultStyle ? GLOBAL_INITIAL_FONTSIZE : (bCurrentDefaultStyle ? Style_GetBaseFontSize() : Style_GetCurrentFontSize())); // Font Height diff --git a/src/Styles.h b/src/Styles.h index 5457b98ec..1889f6cf3 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -30,7 +30,7 @@ #define NUMLEXERS 53 #define AVG_NUM_OF_STYLES_PER_LEXER 20 -void Style_Init(); +void Style_Load(); bool Style_Import(HWND hwnd); bool Style_ImportTheme(const unsigned iThemeIdx); void Style_LoadLexerFileExtensions(); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 91e1c845e..7695feb3a 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -161,6 +161,9 @@ typedef enum #define MB_ICONSHIELD 0x000000B0L #define COLORREF_MAX (DWORD_MAX) + +#define GLOBAL_INITIAL_FONTSIZE 11.0f + // -------------------------------------------------------------------------- typedef enum { CT_NONE = 0, CT_ZOOM, CT_ZEROLEN_MATCH, CT_ENC_INFO, CT_DWELL } CALLTIPTYPE; @@ -365,7 +368,6 @@ typedef struct _globals_t CALLTIPTYPE CallTipType; FILEVARS fvCurFile; int iWrapCol; - int InitialFontSize; bool CmdLnFlag_PosParam; int CmdLnFlag_WindowPos;