[RELEASE] Notepad++ 6.8.2 release

Use default font if font name loaded from stylers.xml cannot be found in
system.
This commit is contained in:
Don Ho 2015-08-20 02:35:38 +02:00
parent 54b04cd284
commit 234e0615db
3 changed files with 24 additions and 2 deletions

View File

@ -1511,6 +1511,18 @@ void NppParameters::setFontList(HWND hWnd)
::EnumFontFamiliesEx(hDC, &lf, EnumFontFamExProc, (LPARAM)&_fontlist, 0);
}
bool NppParameters::isInFontList(const generic_string fontName2Search) const
{
if (fontName2Search.empty())
return false;
for (size_t i = 0, len = _fontlist.size(); i < len; i++)
{
if (_fontlist[i] == fontName2Search)
return true;
}
return false;
}
void NppParameters::getLangKeywordsFromXmlTree()
{

View File

@ -1366,6 +1366,7 @@ public:
void setCurLineHilitingColour(COLORREF colour2Set);
void setFontList(HWND hWnd);
bool isInFontList(const generic_string fontName2Search) const;
const std::vector<generic_string>& getFontList() const { return _fontlist; }
int getNbUserLang() const {return _nbUserLang;}

View File

@ -428,6 +428,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
return _callWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam);
}
#define DEFAULT_FONT_NAME "Courier New"
void ScintillaEditView::setSpecialStyle(const Style & styleToSet)
{
@ -441,8 +442,16 @@ void ScintillaEditView::setSpecialStyle(const Style & styleToSet)
if (styleToSet._fontName && lstrcmp(styleToSet._fontName, TEXT("")) != 0)
{
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
const char * fontNameA = wmc->wchar2char(styleToSet._fontName, CP_UTF8);
execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)fontNameA);
if (not _pParameter->isInFontList(styleToSet._fontName))
{
execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)DEFAULT_FONT_NAME);
}
else
{
const char * fontNameA = wmc->wchar2char(styleToSet._fontName, CP_UTF8);
execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)fontNameA);
}
}
int fontStyle = styleToSet._fontStyle;
if (fontStyle != STYLE_NOT_USED)