Index: reactos/dll/cpl/console/console.h =================================================================== --- reactos/dll/cpl/console/console.h (revision 74316) +++ reactos/dll/cpl/console/console.h (working copy) @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include Index: reactos/dll/cpl/console/font.c =================================================================== --- reactos/dll/cpl/console/font.c (revision 74316) +++ reactos/dll/cpl/console/font.c (working copy) @@ -5,6 +5,7 @@ * PURPOSE: Font dialog * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org) * Hermes Belusca-Maito (hermes.belusca@sfr.fr) + * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) */ #include "console.h" @@ -93,6 +94,28 @@ 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 28, 36, 72 }; +/* Is the user Chinese, Japanese or Korean (CJK)? */ +BYTE GetCJKCharSet(VOID) +{ + LANGID LangID = GetUserDefaultLangID(); + switch (PRIMARYLANGID(LangID)) + { + case LANG_CHINESE: + switch (SUBLANGID(LangID)) + { + case SUBLANG_CHINESE_SIMPLIFIED: + return GB2312_CHARSET; + case SUBLANG_CHINESE_TRADITIONAL: + return CHINESEBIG5_CHARSET; + } + case LANG_JAPANESE: + return SHIFTJIS_CHARSET; + case LANG_KOREAN: + return JOHAB_CHARSET; + } + return DEFAULT_CHARSET; +} + static BOOL CALLBACK EnumFontNamesProc(PLOGFONTW lplf, PNEWTEXTMETRICW lpntm, @@ -101,6 +124,7 @@ { HWND hwndCombo = (HWND)lParam; LPWSTR pszName = lplf->lfFaceName; + BYTE CJKCharSet; /* Record the font's attributes (Fixedwidth and Truetype) */ // BOOL fFixed = ((lplf->lfPitchAndFamily & 0x03) == FIXED_PITCH); @@ -160,23 +184,43 @@ return TRUE; } - /* Reject non-TrueType fonts that are not OEM */ -#if 0 - if ((FontType != TRUETYPE_FONTTYPE) && (lplf->lfCharSet != OEM_CHARSET)) + /* Is the user Chinese, Japanese or Korean? */ + CJKCharSet = GetCJKCharSet(); + if (CJKCharSet != DEFAULT_CHARSET) { - DPRINT1("Non-TrueType font '%S' rejected because it's not OEM_CHARSET %d\n", - pszName, lplf->lfCharSet); - return TRUE; + /* It's Asian */ + if (FontType == TRUETYPE_FONTTYPE) + { + if (lplf->lfCharSet != CJKCharSet) + { + DPRINT1("TrueType font '%S' rejected because it's not user Asian charset (lfCharSet = %d)\n", + pszName, lplf->lfCharSet); + return TRUE; + } + } + else + { + /* Reject non-TrueType fonts that are not Terminal */ + if (wcscmp(pszName, L"Terminal") != 0) + { + DPRINT1("Non-TrueType font '%S' rejected because it's not Terminal\n", pszName); + return TRUE; + } + } } -#else // Improved criterium - if ((FontType != TRUETYPE_FONTTYPE) && - ((lplf->lfCharSet != ANSI_CHARSET) && (lplf->lfCharSet != DEFAULT_CHARSET) && (lplf->lfCharSet != OEM_CHARSET))) + else { - DPRINT1("Non-TrueType font '%S' rejected because it's not ANSI_CHARSET or DEFAULT_CHARSET or OEM_CHARSET (lfCharSet = %d)\n", - pszName, lplf->lfCharSet); - return TRUE; + /* Not CJK */ + if ((FontType != TRUETYPE_FONTTYPE) && + (lplf->lfCharSet != ANSI_CHARSET) && + (lplf->lfCharSet != DEFAULT_CHARSET) && + (lplf->lfCharSet != OEM_CHARSET)) + { + DPRINT1("Non-TrueType font '%S' rejected because it's not ANSI_CHARSET or DEFAULT_CHARSET or OEM_CHARSET (lfCharSet = %d)\n", + pszName, lplf->lfCharSet); + return TRUE; + } } -#endif /* Reject fonts that are vertical (tategaki) */ if (pszName[0] == L'@') @@ -185,17 +229,6 @@ return TRUE; } -#if 0 // For Asian installations only - /* Reject non-TrueType fonts that are not Terminal */ - if ((FontType != TRUETYPE_FONTTYPE) && (wcscmp(pszName, L"Terminal") != 0)) - { - DPRINT1("Non-TrueType font '%S' rejected because it's not Terminal\n", pszName); - return TRUE; - } - - // TODO: Asian TrueType font must also be an Asian character set. -#endif - /* Make sure the font doesn't already exist in the list */ if (SendMessageW(hwndCombo, LB_FINDSTRINGEXACT, 0, (LPARAM)pszName) == LB_ERR) { @@ -392,6 +425,26 @@ (LPARAM)GetDlgItem(hwndDlg, IDC_LBOX_FONTTYPE), 0); ReleaseDC(NULL, hDC); + if (0 == SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, LB_GETCOUNT, 0, 0)) + { + INT i1, i2; + DPRINT1("The ideal console fonts are not found.\n"); + + /* This world is not ideal. We have to do realistically. */ + i1 = SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, LB_ADDSTRING, 0, + (LPARAM)L"Lucida Console"); + SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, + LB_SETITEMDATA, i1, TRUETYPE_FONTTYPE); + + if (GetCJKCharSet() != DEFAULT_CHARSET) + { + i2 = SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, LB_ADDSTRING, 0, + (LPARAM)L"Droid Sans Fallback"); + SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, + LB_SETITEMDATA, i2, TRUETYPE_FONTTYPE); + } + } + DPRINT1("ConInfo->FaceName = '%S'\n", ConInfo->FaceName); idx = (INT)SendDlgItemMessageW(hwndDlg, IDC_LBOX_FONTTYPE, LB_FINDSTRINGEXACT, 0, (LPARAM)ConInfo->FaceName);