From 2d7b2093a198d814d8a69b2f44942637cf11e1c9 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 13 Jun 2022 18:23:17 +0200 Subject: [PATCH] Fix font definition for languages regression in Style Configurator Defining font for languages is no more possible in Style Configurator. This regression is due to commit 1567847 (PR #10483). Fix #11786, close #11787 --- PowerEditor/src/Parameters.cpp | 1 + PowerEditor/src/Parameters.h | 3 +++ .../src/WinControls/ColourPicker/WordStyleDlg.cpp | 12 +++--------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 4bd05ea66..61cab8e00 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -3796,6 +3796,7 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode) if (str) { s._fontName = str; + s._isFontEnabled = true; } str = element->Attribute(TEXT("fontStyle")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index c9c366d82..22988dca3 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -401,9 +401,12 @@ struct Style final COLORREF _fgColor = COLORREF(STYLE_NOT_USED); COLORREF _bgColor = COLORREF(STYLE_NOT_USED); int _colorStyle = COLORSTYLE_ALL; + + bool _isFontEnabled = false; generic_string _fontName; int _fontStyle = FONTSTYLE_NONE; int _fontSize = STYLE_NOT_USED; + int _nesting = FONTSTYLE_NONE; int _keywordClass = STYLE_NOT_USED; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index ff5d6080a..8cfc22c54 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -968,25 +968,22 @@ void WordStyleDlg::setVisualFromStyleList() InvalidateRect(_hBgColourStaticText, NULL, FALSE); //-- font name - isEnable = false; LRESULT iFontName; if (!style._fontName.empty()) { iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, reinterpret_cast(style._fontName.c_str())); if (iFontName == CB_ERR) iFontName = 0; - isEnable = true; } else { iFontName = 0; } ::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0); - ::EnableWindow(_hFontNameCombo, isEnable); + ::EnableWindow(_hFontNameCombo, style._isFontEnabled); InvalidateRect(_hFontNameStaticText, NULL, FALSE); //-- font size - isEnable = false; const size_t intStrLen = 3; TCHAR intStr[intStrLen]; LRESULT iFontSize = 0; @@ -994,14 +991,12 @@ void WordStyleDlg::setVisualFromStyleList() { wsprintf(intStr, TEXT("%d"), style._fontSize); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, reinterpret_cast(intStr)); - isEnable = true; } ::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0); - ::EnableWindow(_hFontSizeCombo, isEnable); + ::EnableWindow(_hFontSizeCombo, style._isFontEnabled); InvalidateRect(_hFontSizeStaticText, NULL, FALSE); //-- font style : bold & italic - isEnable = false; if (style._fontStyle != STYLE_NOT_USED) { int isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; @@ -1010,7 +1005,6 @@ void WordStyleDlg::setVisualFromStyleList() ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); - isEnable = true; } else // STYLE_NOT_USED : reset them all { @@ -1019,7 +1013,7 @@ void WordStyleDlg::setVisualFromStyleList() ::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0); } - enableFontStyle(isEnable); + enableFontStyle(style._isFontEnabled); //-- Default Keywords