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
This commit is contained in:
Don Ho 2022-06-13 18:23:17 +02:00
parent 79e766755d
commit 2d7b2093a1
3 changed files with 7 additions and 9 deletions

View File

@ -3796,6 +3796,7 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
if (str) if (str)
{ {
s._fontName = str; s._fontName = str;
s._isFontEnabled = true;
} }
str = element->Attribute(TEXT("fontStyle")); str = element->Attribute(TEXT("fontStyle"));

View File

@ -401,9 +401,12 @@ struct Style final
COLORREF _fgColor = COLORREF(STYLE_NOT_USED); COLORREF _fgColor = COLORREF(STYLE_NOT_USED);
COLORREF _bgColor = COLORREF(STYLE_NOT_USED); COLORREF _bgColor = COLORREF(STYLE_NOT_USED);
int _colorStyle = COLORSTYLE_ALL; int _colorStyle = COLORSTYLE_ALL;
bool _isFontEnabled = false;
generic_string _fontName; generic_string _fontName;
int _fontStyle = FONTSTYLE_NONE; int _fontStyle = FONTSTYLE_NONE;
int _fontSize = STYLE_NOT_USED; int _fontSize = STYLE_NOT_USED;
int _nesting = FONTSTYLE_NONE; int _nesting = FONTSTYLE_NONE;
int _keywordClass = STYLE_NOT_USED; int _keywordClass = STYLE_NOT_USED;

View File

@ -968,25 +968,22 @@ void WordStyleDlg::setVisualFromStyleList()
InvalidateRect(_hBgColourStaticText, NULL, FALSE); InvalidateRect(_hBgColourStaticText, NULL, FALSE);
//-- font name //-- font name
isEnable = false;
LRESULT iFontName; LRESULT iFontName;
if (!style._fontName.empty()) if (!style._fontName.empty())
{ {
iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, reinterpret_cast<LPARAM>(style._fontName.c_str())); iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, reinterpret_cast<LPARAM>(style._fontName.c_str()));
if (iFontName == CB_ERR) if (iFontName == CB_ERR)
iFontName = 0; iFontName = 0;
isEnable = true;
} }
else else
{ {
iFontName = 0; iFontName = 0;
} }
::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0); ::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0);
::EnableWindow(_hFontNameCombo, isEnable); ::EnableWindow(_hFontNameCombo, style._isFontEnabled);
InvalidateRect(_hFontNameStaticText, NULL, FALSE); InvalidateRect(_hFontNameStaticText, NULL, FALSE);
//-- font size //-- font size
isEnable = false;
const size_t intStrLen = 3; const size_t intStrLen = 3;
TCHAR intStr[intStrLen]; TCHAR intStr[intStrLen];
LRESULT iFontSize = 0; LRESULT iFontSize = 0;
@ -994,14 +991,12 @@ void WordStyleDlg::setVisualFromStyleList()
{ {
wsprintf(intStr, TEXT("%d"), style._fontSize); wsprintf(intStr, TEXT("%d"), style._fontSize);
iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, reinterpret_cast<LPARAM>(intStr)); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, reinterpret_cast<LPARAM>(intStr));
isEnable = true;
} }
::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0); ::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0);
::EnableWindow(_hFontSizeCombo, isEnable); ::EnableWindow(_hFontSizeCombo, style._isFontEnabled);
InvalidateRect(_hFontSizeStaticText, NULL, FALSE); InvalidateRect(_hFontSizeStaticText, NULL, FALSE);
//-- font style : bold & italic //-- font style : bold & italic
isEnable = false;
if (style._fontStyle != STYLE_NOT_USED) if (style._fontStyle != STYLE_NOT_USED)
{ {
int isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; int isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED;
@ -1010,7 +1005,6 @@ void WordStyleDlg::setVisualFromStyleList()
::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0);
::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0);
::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0);
isEnable = true;
} }
else // STYLE_NOT_USED : reset them all else // STYLE_NOT_USED : reset them all
{ {
@ -1019,7 +1013,7 @@ void WordStyleDlg::setVisualFromStyleList()
::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0);
} }
enableFontStyle(isEnable); enableFontStyle(style._isFontEnabled);
//-- Default Keywords //-- Default Keywords