--- a\np2src\scintilla\win32\PlatWin.cxx Wed May 06 07:00:26 2009 +++ b\np2src\scintilla\win32\PlatWin.cxx Thu Jun 25 17:27:33 2009 @@ -26,8 +26,12 @@ #ifndef IDC_HAND #define IDC_HAND MAKEINTRESOURCE(32649) #endif +#ifndef CLEARTYPE_QUALITY +#define CLEARTYPE_QUALITY 5 +#endif + // Take care of 32/64 bit pointers #ifdef GetWindowLongPtr static void *PointerFromWindow(HWND hWnd) { return reinterpret_cast(::GetWindowLongPtr(hWnd, 0)); @@ -186,8 +190,20 @@ static void SetLogFont(LOGFONTA &lf, con lf.lfWeight = bold ? FW_BOLD : FW_NORMAL; lf.lfItalic = static_cast(italic ? 1 : 0); lf.lfCharSet = static_cast(characterSet); strncpy(lf.lfFaceName, faceName, sizeof(lf.lfFaceName)); + + if ( lstrcmpiA(faceName, "Calibri") == 0 || + lstrcmpiA(faceName, "Cambria") == 0 || + lstrcmpiA(faceName, "Candara") == 0 || + lstrcmpiA(faceName, "Consolas") == 0 || + lstrcmpiA(faceName, "Constantia") == 0 || + lstrcmpiA(faceName, "Corbel") == 0 || + lstrcmpiA(faceName, "Segoe UI") == 0 ) + { + // For ClearType-specific fonts, we should enforce ClearType + lf.lfQuality = CLEARTYPE_QUALITY; + } } /** * Create a hash from the parameters for a font to allow easy checking for identity. --- a\np2src\src\Styles.c Sun Jun 21 00:00:00 2009 +++ b\np2src\src\Styles.c Thu Jun 25 17:27:33 2009 @@ -38,9 +38,9 @@ KEYWORDLIST KeyWords_NULL = { "", "", "", "", "", "", "", "", "" }; EDITLEXER lexDefault = { SCLEX_NULL, L"Default Text", L"txt; text; wtx; log; asc; doc; diz; nfo", L"", &KeyWords_NULL, { - /* 0 */ { STYLE_DEFAULT, 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, L"Margins and Line Numbers", L"size:-2; fore:#FF0000", L"" }, /* 2 */ { STYLE_BRACELIGHT, L"Matching Braces", L"size:+1; fore:#FF0000; bold", L"" }, /* 3 */ { STYLE_BRACEBAD, L"Matching Braces Error", L"size:+1; fore:#000080; bold", L"" }, /* 4 */ { STYLE_CONTROLCHAR, L"Control Characters (Unused)", L"", L"" }, @@ -1898,32 +1898,71 @@ BOOL Style_GetOpenDlgFilterStr(LPWSTR lp lstrcpyn(lpszFilter,tchFileDlgFilters,cchFilter-2); lstrcat(lpszFilter,L"||"); } PrepareFilterStr(lpszFilter); 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); +} + + //============================================================================= // // Style_StrGetFont() // BOOL Style_StrGetFont(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont) { WCHAR tch[256]; WCHAR *p; if (p = StrStrI(lpszStyle,L"font:")) { lstrcpy(tch,p + lstrlen(L"font:")); if (p = StrChr(tch,L';')) *p = L'\0'; TrimString(tch); + + 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); + lstrcpyn(lpszFont,tch,cchFont); + } + return TRUE; } return FALSE; } //============================================================================= //