2 * PROJECT: ReactOS Console Configuration DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/console/font.c
6 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 * Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
18 * Current active font, corresponding to the active console font,
19 * and used for painting the text samples.
21 HFONT hCurrentFont
= NULL
;
25 * Standard font pixel/point heights for TrueType fonts
27 static const SHORT TrueTypePoints
[] =
29 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
32 typedef struct _FONTSIZE_LIST_CTL
34 LIST_CTL RasterSizeList
; // ListBox for Raster font sizes; needs to handle bisection.
35 HWND hWndTTSizeList
; // ComboBox for TrueType font sizes.
36 BOOL bIsTTSizeDirty
; // TRUE or FALSE depending on whether we have edited the edit zone.
37 BOOL UseRasterOrTTList
; // TRUE: Use the Raster size list; FALSE: Use the TrueType size list.
38 BOOL TTSizePixelUnit
; // TRUE: Size in pixels (default); FALSE: Size in points.
39 LONG CurrentRasterSize
;
40 LONG CurrentTTSize
; // In whatever unit (pixels or points) currently selected.
41 } FONTSIZE_LIST_CTL
, *PFONTSIZE_LIST_CTL
;
43 /* Used by FontTypeChange() only */
44 static INT CurrentSelFont
= LB_ERR
;
45 static DWORD CurrentFontType
= (DWORD
)-1; // Invalid font type
50 RasterSizeList_GetCount(
53 return (INT
)SendMessageW(ListCtl
->hWndList
, LB_GETCOUNT
, 0, 0);
58 RasterSizeList_GetData(
62 return (ULONG_PTR
)SendMessageW(ListCtl
->hWndList
, LB_GETITEMDATA
, (WPARAM
)Index
, 0);
67 LogicalSizeToPointSize(
77 // LogicalSize = tm.tmHeight - tm.tmInternalLeading;
78 PointSize
= MulDiv(LogicalSize
, 72, GetDeviceCaps(hDC
, LOGPIXELSY
));
87 PointSizeToLogicalSize(
97 LogicalSize
= MulDiv(PointSize
, GetDeviceCaps(hDC
, LOGPIXELSY
), 72);
100 ReleaseDC(NULL
, hDC
);
107 FontSizeList_SelectFontSize(
108 IN PFONTSIZE_LIST_CTL SizeList
,
112 WCHAR szFontSize
[100];
115 // FIXME: Check whether FontSize == 0
116 // (or in the case of raster font maybe, whether HIWORD(FontSize) == Height == 0) ??
119 /* Find and select the best font size in the list corresponding to the current size */
120 if (SizeList
->UseRasterOrTTList
)
124 /* Raster font size (in pixels) */
125 SizeList
->CurrentRasterSize
= FontSize
;
127 nSel
= BisectListSortedByValue(&SizeList
->RasterSizeList
, FontSize
, NULL
, FALSE
);
128 idx
= (INT
)SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_GETCOUNT
, 0, 0);
131 /* Not found, select the first element of the list */
134 else if (nSel
>= idx
)
137 * We got an index beyond the end of the list (as per Bisect* functionality),
138 * so instead, select the last element of the list.
142 SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_SETCURSEL
, (WPARAM
)nSel
, 0);
146 /* TrueType font size (in pixels or points) */
147 SizeList
->CurrentTTSize
= FontSize
;
149 // _ultow(szFontSize, FontSize, 10);
150 StringCchPrintfW(szFontSize
, ARRAYSIZE(szFontSize
), L
"%d", FontSize
);
152 /* Find the font size in the list, or add it both in the ComboBox list, sorted by size value (string), and its edit box */
153 nSel
= SendMessageW(SizeList
->hWndTTSizeList
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)szFontSize
);
156 nSel
= (UINT
)SendMessageW(SizeList
->hWndTTSizeList
, CB_ADDSTRING
, -1, (LPARAM
)szFontSize
);
157 // ComboBox_SetText(...)
158 SetWindowTextW(SizeList
->hWndTTSizeList
, szFontSize
);
159 SizeList
->bIsTTSizeDirty
= TRUE
;
161 SendMessageW(SizeList
->hWndTTSizeList
, CB_SETCURSEL
, (WPARAM
)nSel
, 0);
166 FontSizeList_GetSelectedFontSize(
167 IN PFONTSIZE_LIST_CTL SizeList
)
171 WCHAR szFontSize
[100];
173 if (SizeList
->UseRasterOrTTList
)
175 /* Raster font size (in pixels) */
177 nSel
= (INT
)SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_GETCURSEL
, 0, 0);
178 if (nSel
== LB_ERR
) return 0;
180 FontSize
= (LONG
)SizeList
->RasterSizeList
.GetData(&SizeList
->RasterSizeList
, nSel
);
181 if (FontSize
== LB_ERR
) return 0;
183 SizeList
->CurrentRasterSize
= FontSize
;
187 /* TrueType font size (in pixels or points) */
189 if (!SizeList
->bIsTTSizeDirty
)
192 * The user just selected an existing size, read the ComboBox selection.
194 * See: https://support.microsoft.com/en-us/help/66365/how-to-process-a-cbn-selchange-notification-message
197 nSel
= SendMessageW(SizeList
->hWndTTSizeList
, CB_GETCURSEL
, 0, 0);
198 SendMessageW(SizeList
->hWndTTSizeList
, CB_GETLBTEXT
, nSel
, (LPARAM
)szFontSize
);
202 /* Read the ComboBox edit string, as the user has entered a custom size */
203 // ComboBox_GetText(...)
204 GetWindowTextW(SizeList
->hWndTTSizeList
, szFontSize
, ARRAYSIZE(szFontSize
));
207 nSel
= SendMessageW(SizeList
->hWndTTSizeList
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)szFontSize
);
210 nSel
= (UINT
)SendMessageW(SizeList
->hWndTTSizeList
, CB_ADDSTRING
, -1, (LPARAM
)szFontSize
);
211 //// ComboBox_SetText(...)
212 //SetWindowTextW(SizeList->hWndTTSizeList, szFontSize);
213 //SizeList->bIsTTSizeDirty = TRUE;
215 SendMessageW(SizeList
->hWndTTSizeList
, CB_SETCURSEL
, (WPARAM
)nSel
, 0);
218 SizeList
->bIsTTSizeDirty
= FALSE
;
220 /* If _wtol fails and returns 0, the font size is considered invalid */
221 // FontSize = wcstoul(szFontSize, &pszNext, 10); if (!*pszNext) { /* Error */ }
222 FontSize
= _wtol(szFontSize
);
223 if (FontSize
== 0) return 0;
225 SizeList
->CurrentTTSize
= FontSize
;
228 * If the font size is given in points, instead of pixels,
229 * convert it into logical size.
231 if (!SizeList
->TTSizePixelUnit
)
232 FontSize
= -PointSizeToLogicalSize(NULL
, FontSize
);
242 IN LPCWSTR pszFaceName
,
247 /* Make sure the font doesn't already exist in the list */
248 if (SendMessageW(hWndList
, LB_FINDSTRINGEXACT
, 0, (LPARAM
)pszFaceName
) != LB_ERR
)
252 iItem
= (INT
)SendMessageW(hWndList
, LB_ADDSTRING
, 0, (LPARAM
)pszFaceName
);
255 DPRINT1("Failed to add font '%S'\n", pszFaceName
);
259 DPRINT1("Add font '%S'\n", pszFaceName
);
261 /* Store this information in the list-item's userdata area */
262 // SendMessageW(hWndList, LB_SETITEMDATA, idx, MAKELPARAM(fFixed, fTrueType));
263 SendMessageW(hWndList
, LB_SETITEMDATA
, iItem
, (LPARAM
)FontType
);
266 typedef struct _FACE_NAMES_PROC_PARAM
270 } FACE_NAMES_PROC_PARAM
, *PFACE_NAMES_PROC_PARAM
;
275 IN PNEWTEXTMETRICW lpntm
,
279 PFACE_NAMES_PROC_PARAM Param
= (PFACE_NAMES_PROC_PARAM
)lParam
;
282 * To install additional TrueType fonts to be available for the console,
283 * add entries of type REG_SZ named "0", "00" etc... in:
284 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
285 * The names of the fonts listed there should match those in:
286 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
288 if (IsValidConsoleFont2(lplf
, lpntm
, FontType
, Param
->CodePage
))
290 /* Add the font to the list */
291 AddFontToList(Param
->hWndList
, lplf
->lfFaceName
, FontType
);
294 /* Continue the font enumeration */
301 IN PNEWTEXTMETRICW lpntm
,
305 PFONTSIZE_LIST_CTL SizeList
= (PFONTSIZE_LIST_CTL
)lParam
;
306 UINT iItem
, iDupItem
;
307 WCHAR szFontSize
[100];
309 if (FontType
!= TRUETYPE_FONTTYPE
)
315 * Width = FontSize.X = LOWORD(FontSize);
316 * Height = FontSize.Y = HIWORD(FontSize);
319 StringCchPrintfW(szFontSize
, ARRAYSIZE(szFontSize
), L
"%d x %d", lplf
->lfWidth
, lplf
->lfHeight
);
320 FontSize
= MAKEWPARAM(lplf
->lfWidth
, lplf
->lfHeight
);
322 /* Add the font size into the list, sorted by size value. Avoid any duplicates. */
323 /* Store this information in the list-item's userdata area */
325 iItem
= BisectListSortedByValue(&SizeList
->RasterSizeList
, FontSize
, &iDupItem
, TRUE
);
328 if (iDupItem
== LB_ERR
)
330 iItem
= (UINT
)SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_INSERTSTRING
, iItem
, (LPARAM
)szFontSize
);
331 if (iItem
!= LB_ERR
&& iItem
!= LB_ERRSPACE
)
332 iItem
= SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_SETITEMDATA
, iItem
, FontSize
);
339 /* TrueType or vectored font: list all the hardcoded font points */
341 for (i
= 0; i
< ARRAYSIZE(TrueTypePoints
); ++i
)
343 // _ultow(szFontSize, TrueTypePoints[i], 10);
344 StringCchPrintfW(szFontSize
, ARRAYSIZE(szFontSize
), L
"%d", TrueTypePoints
[i
]);
346 /* Add the font size into the list, sorted by size value (string). Avoid any duplicates. */
347 if (SendMessageW(SizeList
->hWndTTSizeList
, CB_FINDSTRINGEXACT
, 0, (LPARAM
)szFontSize
) == CB_ERR
)
348 iItem
= (UINT
)SendMessageW(SizeList
->hWndTTSizeList
, CB_INSERTSTRING
, -1, (LPARAM
)szFontSize
);
351 /* Stop the enumeration now */
357 FaceNameList_Initialize(
361 FACE_NAMES_PROC_PARAM Param
;
366 Param
.hWndList
= hWndList
;
367 Param
.CodePage
= CodePage
;
369 ZeroMemory(&lf
, sizeof(lf
));
370 lf
.lfCharSet
= DEFAULT_CHARSET
; // CodePageToCharSet(CodePage);
371 // lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
374 EnumFontFamiliesExW(hDC
, &lf
, (FONTENUMPROCW
)EnumFaceNamesProc
, (LPARAM
)&Param
, 0);
375 ReleaseDC(NULL
, hDC
);
377 idx
= (INT
)SendMessageW(hWndList
, LB_GETCOUNT
, 0, 0);
378 if (idx
!= LB_ERR
&& idx
!= 0)
380 /* We have found some fonts and filled the list, we are fine! */
384 /* No fonts were found. Manually add default ones into the list. */
385 DPRINT1("The ideal console fonts were not found; manually add default ones.\n");
387 AddFontToList(hWndList
, L
"Terminal", RASTER_FONTTYPE
);
388 AddFontToList(hWndList
, L
"Lucida Console", TRUETYPE_FONTTYPE
);
389 if (CodePageToCharSet(CodePage
) != DEFAULT_CHARSET
)
390 AddFontToList(hWndList
, L
"Droid Sans Fallback", TRUETYPE_FONTTYPE
);
394 FaceNameList_SelectFaceName(
400 iItem
= (INT
)SendMessageW(hWndList
, LB_FINDSTRINGEXACT
, 0, (LPARAM
)FaceName
);
402 iItem
= (INT
)SendMessageW(hWndList
, LB_FINDSTRINGEXACT
, 0, (LPARAM
)L
"Terminal");
405 SendMessageW(hWndList
, LB_SETCURSEL
, (WPARAM
)iItem
, 0);
413 IN PFONTSIZE_LIST_CTL SizeList
)
417 if (SizeList
->UseRasterOrTTList
)
420 * Raster font: show the Raster size list, and
421 * hide the TrueType size list and the units.
424 // EnableDlgItem(hDlg, IDC_CHECK_BOLD_FONTS, FALSE);
426 hDlgItem
= GetDlgItem(hDlg
, IDC_RADIO_PIXEL_UNIT
);
427 ShowWindow(hDlgItem
, SW_HIDE
);
428 EnableWindow(hDlgItem
, FALSE
);
430 hDlgItem
= GetDlgItem(hDlg
, IDC_RADIO_POINT_UNIT
);
431 ShowWindow(hDlgItem
, SW_HIDE
);
432 EnableWindow(hDlgItem
, FALSE
);
434 hDlgItem
= SizeList
->hWndTTSizeList
;
435 ShowWindow(hDlgItem
, SW_HIDE
);
436 EnableWindow(hDlgItem
, FALSE
);
438 hDlgItem
= SizeList
->RasterSizeList
.hWndList
;
439 EnableWindow(hDlgItem
, TRUE
);
440 ShowWindow(hDlgItem
, SW_SHOW
);
445 * TrueType font: show the TrueType size list
446 * and the units, and hide the Raster size list.
449 // EnableDlgItem(hDlg, IDC_CHECK_BOLD_FONTS, TRUE);
451 hDlgItem
= SizeList
->RasterSizeList
.hWndList
;
452 ShowWindow(hDlgItem
, SW_HIDE
);
453 EnableWindow(hDlgItem
, FALSE
);
455 hDlgItem
= SizeList
->hWndTTSizeList
;
456 EnableWindow(hDlgItem
, TRUE
);
457 ShowWindow(hDlgItem
, SW_SHOW
);
459 hDlgItem
= GetDlgItem(hDlg
, IDC_RADIO_PIXEL_UNIT
);
460 EnableWindow(hDlgItem
, TRUE
);
461 ShowWindow(hDlgItem
, SW_SHOW
);
463 hDlgItem
= GetDlgItem(hDlg
, IDC_RADIO_POINT_UNIT
);
464 EnableWindow(hDlgItem
, TRUE
);
465 ShowWindow(hDlgItem
, SW_SHOW
);
472 IN PFONTSIZE_LIST_CTL SizeList
,
473 IN OUT PCONSOLE_STATE_INFO pConInfo
);
478 IN PFONTSIZE_LIST_CTL SizeList
,
479 IN OUT PCONSOLE_STATE_INFO pConInfo
)
481 HWND hListBox
= GetDlgItem(hDlg
, IDC_LBOX_FONTTYPE
);
486 LPCWSTR FontGrpBoxLabelTpl
= NULL
;
487 WCHAR FontGrpBoxLabel
[260];
489 nSel
= (INT
)SendMessageW(hListBox
, LB_GETCURSEL
, 0, 0);
490 if (nSel
== LB_ERR
) return FALSE
;
493 * This is disabled, because there can be external parameters
494 * that may have changed (e.g. ConInfo->FontWeight, code page, ...)
495 * and that we don't control here, and that need a font refresh.
498 /* Check whether the selection has changed */
499 if (nSel
== CurrentSelFont
)
503 Length
= (INT
)SendMessageW(hListBox
, LB_GETTEXTLEN
, nSel
, 0);
504 if (Length
== LB_ERR
) return FALSE
;
506 FaceName
= HeapAlloc(GetProcessHeap(),
508 (Length
+ 1) * sizeof(WCHAR
));
509 if (FaceName
== NULL
) return FALSE
;
511 Length
= (INT
)SendMessageW(hListBox
, LB_GETTEXT
, nSel
, (LPARAM
)FaceName
);
512 FaceName
[Length
] = L
'\0';
514 StringCchCopyW(pConInfo
->FaceName
, ARRAYSIZE(pConInfo
->FaceName
), FaceName
);
515 DPRINT1("pConInfo->FaceName = '%S'\n", pConInfo
->FaceName
);
517 ZeroMemory(&lf
, sizeof(lf
));
518 lf
.lfCharSet
= DEFAULT_CHARSET
; // CodePageToCharSet(pConInfo->CodePage);
519 // lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
520 StringCchCopyW(lf
.lfFaceName
, ARRAYSIZE(lf
.lfFaceName
), FaceName
);
523 * Retrieve the read-only font group box label string template,
524 * and set the group box label to the name of the selected font.
526 Length
= LoadStringW(hApplet
, IDS_GROUPBOX_FONT_NAME
, (LPWSTR
)&FontGrpBoxLabelTpl
, 0);
527 if (FontGrpBoxLabelTpl
&& Length
> 0)
529 StringCchCopyNW(FontGrpBoxLabel
, ARRAYSIZE(FontGrpBoxLabel
), FontGrpBoxLabelTpl
, Length
);
530 StringCchCatW(FontGrpBoxLabel
, ARRAYSIZE(FontGrpBoxLabel
), FaceName
);
531 SetDlgItemTextW(hDlg
, IDC_GROUPBOX_FONT_NAME
, FontGrpBoxLabel
);
534 HeapFree(GetProcessHeap(), 0, FaceName
);
537 * Reset the font size list, only:
538 * - if we have changed the type of font, or
539 * - if the font type is the same and is RASTER but the font has changed.
540 * Otherwise, if the font type is not RASTER and has not changed,
541 * we always display the TrueType default sizes and we don't need to
542 * recreate the list when we change between different TrueType fonts.
544 FontType
= SendMessageW(hListBox
, LB_GETITEMDATA
, nSel
, 0);
545 if (FontType
!= LB_ERR
)
547 SizeList
->UseRasterOrTTList
= (FontType
== RASTER_FONTTYPE
);
549 /* Display the correct font size list (if needed) */
550 if (CurrentFontType
!= FontType
)
551 UpdateFontSizeList(hDlg
, SizeList
);
553 /* Enumerate the available sizes for the selected font */
554 if ((CurrentFontType
!= FontType
) ||
555 (FontType
== RASTER_FONTTYPE
&& CurrentSelFont
!= nSel
))
559 if (SizeList
->UseRasterOrTTList
)
560 SendMessageW(SizeList
->RasterSizeList
.hWndList
, LB_RESETCONTENT
, 0, 0);
562 SendMessageW(SizeList
->hWndTTSizeList
, CB_RESETCONTENT
, 0, 0);
565 EnumFontFamiliesExW(hDC
, &lf
, (FONTENUMPROCW
)EnumFontSizesProc
, (LPARAM
)SizeList
, 0);
566 ReleaseDC(NULL
, hDC
);
568 /* Re-select the current font size */
569 if (SizeList
->UseRasterOrTTList
)
570 FontSizeList_SelectFontSize(SizeList
, SizeList
->CurrentRasterSize
);
572 FontSizeList_SelectFontSize(SizeList
, SizeList
->CurrentTTSize
);
577 /* We failed, display the raster fonts size list */
578 SizeList
->UseRasterOrTTList
= TRUE
;
579 UpdateFontSizeList(hDlg
, SizeList
);
581 CurrentFontType
= FontType
;
582 CurrentSelFont
= nSel
;
584 FontSizeChange(hDlg
, SizeList
, pConInfo
);
591 IN PFONTSIZE_LIST_CTL SizeList
,
592 IN OUT PCONSOLE_STATE_INFO pConInfo
)
595 LONG CharWidth
, CharHeight
, FontSize
;
596 WCHAR szFontSize
[100];
599 * Retrieve the current selected font size.
600 * - If SizeList->UseRasterOrTTList is TRUE, or if it is FALSE but
601 * if SizeList->TTSizePixelUnit is TRUE, then the font size is in pixels;
602 * - If SizeList->TTSizePixelUnit is FALSE, then the font size is in points.
604 FontSize
= FontSizeList_GetSelectedFontSize(SizeList
);
605 CharHeight
= (SizeList
->UseRasterOrTTList
? (LONG
)HIWORD(FontSize
) : FontSize
);
606 CharWidth
= (SizeList
->UseRasterOrTTList
? (LONG
)LOWORD(FontSize
) : 0);
608 if (hCurrentFont
) DeleteObject(hCurrentFont
);
609 hCurrentFont
= CreateConsoleFont2(CharHeight
, CharWidth
, pConInfo
);
610 if (hCurrentFont
== NULL
)
611 DPRINT1("FontSizeChange: CreateConsoleFont2 failed\n");
613 /* Retrieve the real character size in pixels */
615 GetFontCellSize(hDC
, hCurrentFont
, (PUINT
)&CharHeight
, (PUINT
)&CharWidth
);
616 ReleaseDC(NULL
, hDC
);
620 * Width = FontSize.X = LOWORD(FontSize);
621 * Height = FontSize.Y = HIWORD(FontSize);
623 pConInfo
->FontSize
.X
= (SHORT
)(SizeList
->UseRasterOrTTList
? CharWidth
: 0);
624 pConInfo
->FontSize
.Y
= (SHORT
)CharHeight
;
626 DPRINT1("pConInfo->FontSize = (%d x %d) ; (CharWidth x CharHeight) = (%d x %d)\n",
627 pConInfo
->FontSize
.X
, pConInfo
->FontSize
.Y
, CharWidth
, CharHeight
);
629 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_FONT_WINDOW_PREVIEW
), NULL
, TRUE
);
630 InvalidateRect(GetDlgItem(hDlg
, IDC_STATIC_SELECT_FONT_PREVIEW
), NULL
, TRUE
);
632 StringCchPrintfW(szFontSize
, ARRAYSIZE(szFontSize
), L
"%d", CharWidth
);
633 SetDlgItemText(hDlg
, IDC_FONT_SIZE_X
, szFontSize
);
634 StringCchPrintfW(szFontSize
, ARRAYSIZE(szFontSize
), L
"%d", CharHeight
);
635 SetDlgItemText(hDlg
, IDC_FONT_SIZE_Y
, szFontSize
);
648 PFONTSIZE_LIST_CTL SizeList
;
650 SizeList
= (PFONTSIZE_LIST_CTL
)GetWindowLongPtrW(hDlg
, DWLP_USER
);
656 HWND hFontList
= GetDlgItem(hDlg
, IDC_LBOX_FONTTYPE
);
658 SizeList
= (PFONTSIZE_LIST_CTL
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*SizeList
));
662 return (INT_PTR
)TRUE
;
664 SizeList
->RasterSizeList
.hWndList
= GetDlgItem(hDlg
, IDC_LBOX_FONTSIZE
);
665 SizeList
->RasterSizeList
.GetCount
= RasterSizeList_GetCount
;
666 SizeList
->RasterSizeList
.GetData
= RasterSizeList_GetData
;
667 SizeList
->hWndTTSizeList
= GetDlgItem(hDlg
, IDC_CBOX_FONTSIZE
);
668 SizeList
->bIsTTSizeDirty
= FALSE
;
669 SetWindowLongPtrW(hDlg
, DWLP_USER
, (LONG_PTR
)SizeList
);
671 /* By default show the raster font size list */
672 SizeList
->UseRasterOrTTList
= TRUE
;
674 /* By default show the font sizes in pixel units */
675 CheckRadioButton(hDlg
, IDC_RADIO_PIXEL_UNIT
, IDC_RADIO_POINT_UNIT
, IDC_RADIO_PIXEL_UNIT
);
676 SizeList
->TTSizePixelUnit
= TRUE
;
678 UpdateFontSizeList(hDlg
, SizeList
);
680 /* Initialize the font list */
681 FaceNameList_Initialize(hFontList
, ConInfo
->CodePage
);
683 /* Select the current font */
684 DPRINT1("ConInfo->FaceName = '%S'\n", ConInfo
->FaceName
);
685 FaceNameList_SelectFaceName(hFontList
, ConInfo
->FaceName
);
687 if (ConInfo
->FontWeight
>= FW_BOLD
)
688 CheckDlgButton(hDlg
, IDC_CHECK_BOLD_FONTS
, BST_CHECKED
);
690 CheckDlgButton(hDlg
, IDC_CHECK_BOLD_FONTS
, BST_UNCHECKED
);
692 /* Select the current font size */
695 * Width = FontSize.X = LOWORD(FontSize);
696 * Height = FontSize.Y = HIWORD(FontSize);
698 SizeList
->CurrentRasterSize
= MAKELONG(ConInfo
->FontSize
.X
, ConInfo
->FontSize
.Y
);
699 SizeList
->CurrentTTSize
= ConInfo
->FontSize
.Y
;
700 // FontSizeList_SelectFontSize(SizeList, SizeList->CurrentRasterSize);
702 /* Refresh everything */
703 FontTypeChange(hDlg
, SizeList
, ConInfo
);
711 HeapFree(GetProcessHeap(), 0, SizeList
);
712 return (INT_PTR
)TRUE
;
717 LPDRAWITEMSTRUCT drawItem
= (LPDRAWITEMSTRUCT
)lParam
;
719 if (drawItem
->CtlID
== IDC_STATIC_FONT_WINDOW_PREVIEW
)
720 PaintConsole(drawItem
, ConInfo
);
721 else if (drawItem
->CtlID
== IDC_STATIC_SELECT_FONT_PREVIEW
)
722 PaintText(drawItem
, ConInfo
, Screen
);
729 switch (((LPNMHDR
)lParam
)->code
)
733 ApplyConsoleInfo(hDlg
);
743 if (HIWORD(wParam
) == LBN_SELCHANGE
/* || CBN_SELCHANGE */)
745 switch (LOWORD(wParam
))
747 case IDC_LBOX_FONTTYPE
:
749 /* Change the property sheet state only if the font has really changed */
750 if (FontTypeChange(hDlg
, SizeList
, ConInfo
))
751 PropSheet_Changed(GetParent(hDlg
), hDlg
);
755 case IDC_LBOX_FONTSIZE
:
756 case IDC_CBOX_FONTSIZE
:
758 /* Change the property sheet state only if the font has really changed */
759 if (FontSizeChange(hDlg
, SizeList
, ConInfo
))
760 PropSheet_Changed(GetParent(hDlg
), hDlg
);
765 /* NOTE: CBN_EDITUPDATE is sent first, and is followed by CBN_EDITCHANGE */
766 else if (HIWORD(wParam
) == CBN_EDITUPDATE
&& LOWORD(wParam
) == IDC_CBOX_FONTSIZE
)
769 PWCHAR pszNext
= NULL
;
770 WCHAR szFontSize
[100];
771 WCHAR szMessage
[260];
773 GetWindowTextW(SizeList
->hWndTTSizeList
, szFontSize
, ARRAYSIZE(szFontSize
));
774 FontSize
= wcstoul(szFontSize
, &pszNext
, 10);
778 StringCchPrintfW(szMessage
, ARRAYSIZE(szMessage
), L
"\"%s\" is not a valid font size.", szFontSize
);
779 MessageBoxW(hDlg
, szMessage
, L
"Error", MB_ICONINFORMATION
| MB_OK
);
780 FontSizeList_SelectFontSize(SizeList
, FontSize
);
782 /**/SizeList
->bIsTTSizeDirty
= TRUE
;/**/
784 else if (HIWORD(wParam
) == CBN_KILLFOCUS
&& LOWORD(wParam
) == IDC_CBOX_FONTSIZE
)
786 /* Change the property sheet state only if the font has really changed */
787 if (FontSizeChange(hDlg
, SizeList
, ConInfo
))
788 PropSheet_Changed(GetParent(hDlg
), hDlg
);
791 if (HIWORD(wParam
) == BN_CLICKED
)
793 switch (LOWORD(wParam
))
795 case IDC_CHECK_BOLD_FONTS
:
797 if (IsDlgButtonChecked(hDlg
, IDC_CHECK_BOLD_FONTS
) == BST_CHECKED
)
798 ConInfo
->FontWeight
= FW_BOLD
;
800 ConInfo
->FontWeight
= FW_NORMAL
;
802 FontTypeChange(hDlg
, SizeList
, ConInfo
);
803 PropSheet_Changed(GetParent(hDlg
), hDlg
);
807 case IDC_RADIO_PIXEL_UNIT
:
808 case IDC_RADIO_POINT_UNIT
:
810 SizeList
->TTSizePixelUnit
= (LOWORD(wParam
) == IDC_RADIO_PIXEL_UNIT
);
812 /* The call is valid only for TrueType fonts */
813 if (CurrentFontType
!= TRUETYPE_FONTTYPE
)
816 /* Change the property sheet state only if the font has really changed */
817 if (FontSizeChange(hDlg
, SizeList
, ConInfo
))
818 PropSheet_Changed(GetParent(hDlg
), hDlg
);