Permalink
Browse files

kliu: default font = consolas patch

http://code.kliu.org/misc/notepad2/
np2-4.0.22-default_font.patch

Does not include Scintilla patch, as this change is already merged into
Scintilla 2.11

Signed-off-by: Dan Savilonis <djs@n-cube.org>
  • Loading branch information...
djs committed May 17, 2010
1 parent b51cb94 commit d2ccfa80f238db7ff7980b43ff4f76e637eb6c46
Showing with 39 additions and 2 deletions.
  1. +39 −2 src/Styles.c
View
@@ -42,7 +42,7 @@ KEYWORDLIST KeyWords_NULL = {
EDITLEXER lexDefault = { SCLEX_NULL, 63000, L"Default Text", L"txt; text; wtx; log; asc; doc; diz; nfo", L"", &KeyWords_NULL, {
- /* 0 */ { STYLE_DEFAULT, 63100, L"Default Style", L"font:Lucida Console; size:10", L"" },
+ /* 0 */ { STYLE_DEFAULT, L"Default Style", L"font:Default; size:10", L"" },
/* 1 */ { STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" },
/* 2 */ { STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+1; bold; fore:#FF0000", L"" },
/* 3 */ { STYLE_BRACEBAD, 63103, L"Matching Braces Error", L"size:+1; bold; fore:#000080", L"" },
@@ -1915,6 +1915,31 @@ BOOL Style_GetOpenDlgFilterStr(LPWSTR lpszFilter,int cchFilter)
return TRUE;
}
+//=============================================================================
+//
+// IsConsolasAvailable()
+//
+int CALLBACK EnumFontsProc( CONST LOGFONT *plf, CONST TEXTMETRIC *ptm,
+ DWORD FontType, LPARAM lParam )
+{
+ *((PBOOL)lParam) = TRUE;
+ return(FALSE);
+}
+
+BOOL IsConsolasAvailable( )
+{
+ // Yes, EnumFonts is old, but we neither need nor care about the additional
+ // info returned by the newer font enumeration APIs; all that we care about
+ // is whether the callback is ever called.
+
+ BOOL fFound = FALSE;
+
+ HDC hDC = GetDC(NULL);
+ EnumFonts(hDC, TEXT("Consolas"), EnumFontsProc, (LPARAM)&fFound);
+ ReleaseDC(NULL, hDC);
+
+ return(fFound);
+}
//=============================================================================
//
@@ -1931,7 +1956,19 @@ BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont)
if (p = StrChr(tch,L';'))
*p = L'\0';
TrimString(tch);
- lstrcpyn(lpszFont,tch,cchFont);
+
+ if (lstrcmpi(tch,L"Default") == 0)
+ {
+ if (IsConsolasAvailable())
+ lstrcpyn(lpszFont,L"Consolas",cchFont);
+ else
+ lstrcpyn(lpszFont,L"Lucida Console",cchFont);
+ }
+ else
+ {
+ lstrcpyn(lpszFont,tch,cchFont);
+ }
+
return TRUE;
}
return FALSE;

0 comments on commit d2ccfa8

Please sign in to comment.