ReactOS 0.4.15-dev-8339-g4028de8
font.c File Reference
#include "console.h"
#include <debug.h>
Include dependency graph for font.c:

Go to the source code of this file.

Classes

struct  _FONTSIZE_LIST_CTL
 
struct  _FACE_NAMES_PROC_PARAM
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _FONTSIZE_LIST_CTL FONTSIZE_LIST_CTL
 
typedef struct _FONTSIZE_LIST_CTLPFONTSIZE_LIST_CTL
 
typedef struct _FACE_NAMES_PROC_PARAM FACE_NAMES_PROC_PARAM
 
typedef struct _FACE_NAMES_PROC_PARAMPFACE_NAMES_PROC_PARAM
 

Functions

VOID RefreshFontPreview (IN FONT_PREVIEW *Preview, IN PCONSOLE_STATE_INFO pConInfo)
 
VOID UpdateFontPreview (IN FONT_PREVIEW *Preview, IN HFONT hFont, IN UINT CharWidth, IN UINT CharHeight)
 
static INT RasterSizeList_GetCount (IN PLIST_CTL ListCtl)
 
static ULONG_PTR RasterSizeList_GetData (IN PLIST_CTL ListCtl, IN INT Index)
 
INT LogicalSizeToPointSize (IN HDC hDC OPTIONAL, IN UINT LogicalSize)
 
INT PointSizeToLogicalSize (IN HDC hDC OPTIONAL, IN INT PointSize)
 
static VOID FontSizeList_SelectFontSize (IN PFONTSIZE_LIST_CTL SizeList, IN ULONG FontSize)
 
static LONG FontSizeList_GetSelectedFontSize (IN PFONTSIZE_LIST_CTL SizeList)
 
static VOID AddFontToList (IN HWND hWndList, IN LPCWSTR pszFaceName, IN DWORD FontType)
 
static BOOL CALLBACK EnumFaceNamesProc (IN PLOGFONTW lplf, IN PNEWTEXTMETRICW lpntm, IN DWORD FontType, IN LPARAM lParam)
 
static BOOL CALLBACK EnumFontSizesProc (IN PLOGFONTW lplf, IN PNEWTEXTMETRICW lpntm, IN DWORD FontType, IN LPARAM lParam)
 
static VOID FaceNameList_Initialize (IN HWND hWndList, IN UINT CodePage)
 
static VOID FaceNameList_SelectFont (IN HWND hDlg, IN HWND hWndList, IN PFONTSIZE_LIST_CTL SizeList, IN LPCWSTR FaceName, IN ULONG FontFamily, IN ULONG FontWeight, IN COORD FontSize)
 
static VOID UpdateFontSizeList (IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList)
 
static BOOL FontSizeChange (IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList, IN OUT PCONSOLE_STATE_INFO pConInfo)
 
static BOOL FontTypeChange (IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList, IN OUT PCONSOLE_STATE_INFO pConInfo)
 
INT_PTR CALLBACK FontProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

FONT_PREVIEW FontPreview = {NULL, 0, 0}
 
static const SHORT TrueTypePoints []
 
static INT CurrentSelFont = LB_ERR
 
static DWORD CurrentFontType = (DWORD)-1
 
static UINT CurrentCodePage = INVALID_CP
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file font.c.

Typedef Documentation

◆ FACE_NAMES_PROC_PARAM

◆ FONTSIZE_LIST_CTL

◆ PFACE_NAMES_PROC_PARAM

◆ PFONTSIZE_LIST_CTL

Function Documentation

◆ AddFontToList()

static VOID AddFontToList ( IN HWND  hWndList,
IN LPCWSTR  pszFaceName,
IN DWORD  FontType 
)
static

Definition at line 288 of file font.c.

292{
293 INT iItem;
294
295 /* Make sure the font doesn't already exist in the list */
296 if (SendMessageW(hWndList, LB_FINDSTRINGEXACT, 0, (LPARAM)pszFaceName) != LB_ERR)
297 return;
298
299 /* Add the font */
300 iItem = (INT)SendMessageW(hWndList, LB_ADDSTRING, 0, (LPARAM)pszFaceName);
301 if (iItem == LB_ERR)
302 {
303 DPRINT1("Failed to add font '%S'\n", pszFaceName);
304 return;
305 }
306
307 DPRINT1("Add font '%S'\n", pszFaceName);
308
309 /* Store this information in the list-item's userdata area */
310 // SendMessageW(hWndList, LB_SETITEMDATA, idx, MAKELPARAM(fFixed, fTrueType));
311 SendMessageW(hWndList, LB_SETITEMDATA, iItem, (LPARAM)FontType);
312}
static HWND hWndList[5+1]
Definition: SetParent.c:10
#define DPRINT1
Definition: precomp.h:8
#define INT
Definition: polytest.cpp:20
int32_t INT
Definition: typedefs.h:58
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_ERR
Definition: winuser.h:2432
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2035
#define LB_ADDSTRING
Definition: winuser.h:2031
#define LB_SETITEMDATA
Definition: winuser.h:2065
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by EnumFaceNamesProc(), and FaceNameList_Initialize().

◆ EnumFaceNamesProc()

static BOOL CALLBACK EnumFaceNamesProc ( IN PLOGFONTW  lplf,
IN PNEWTEXTMETRICW  lpntm,
IN DWORD  FontType,
IN LPARAM  lParam 
)
static

Definition at line 321 of file font.c.

326{
328
329 if (IsValidConsoleFont2(lplf, lpntm, FontType, Param->CodePage))
330 {
331 /* Add the face name to the list */
332 AddFontToList(Param->hWndList, lplf->lfFaceName, FontType);
333 }
334
335 /* Continue enumerating the faces */
336 return TRUE;
337}
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
static VOID AddFontToList(IN HWND hWndList, IN LPCWSTR pszFaceName, IN DWORD FontType)
Definition: font.c:288
struct _FACE_NAMES_PROC_PARAM * PFACE_NAMES_PROC_PARAM
BOOL IsValidConsoleFont2(_In_ PLOGFONTW lplf, _In_ PNEWTEXTMETRICW lpntm, _In_ DWORD FontType, _In_ UINT CodePage)
Validates whether a given font can be supported in the console, under the specified code page.
Definition: font.c:782

Referenced by FaceNameList_Initialize().

◆ EnumFontSizesProc()

static BOOL CALLBACK EnumFontSizesProc ( IN PLOGFONTW  lplf,
IN PNEWTEXTMETRICW  lpntm,
IN DWORD  FontType,
IN LPARAM  lParam 
)
static

Definition at line 340 of file font.c.

345{
347 UINT iItem, iDupItem;
348 WCHAR szFontSize[100];
349
350 if (FontType != TRUETYPE_FONTTYPE)
351 {
352 WPARAM FontSize;
353
354 /*
355 * Format:
356 * Width = FontSize.X = LOWORD(FontSize);
357 * Height = FontSize.Y = HIWORD(FontSize);
358 */
359
360 StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d x %d", lplf->lfWidth, lplf->lfHeight);
361 FontSize = MAKEWPARAM(lplf->lfWidth, lplf->lfHeight);
362
363 /* Add the font size into the list, sorted by size value. Avoid any duplicates. */
364 /* Store this information in the list-item's userdata area */
365 iDupItem = LB_ERR;
366 iItem = BisectListSortedByValue(&SizeList->RasterSizeList, FontSize, &iDupItem, TRUE);
367 if (iItem == LB_ERR)
368 iItem = 0;
369 if (iDupItem == LB_ERR)
370 {
371 iItem = (UINT)SendMessageW(SizeList->RasterSizeList.hWndList, LB_INSERTSTRING, iItem, (LPARAM)szFontSize);
372 if (iItem != LB_ERR && iItem != LB_ERRSPACE)
373 iItem = SendMessageW(SizeList->RasterSizeList.hWndList, LB_SETITEMDATA, iItem, FontSize);
374 }
375
376 return TRUE;
377 }
378 else
379 {
380 /* TrueType or vectored font: list all the hardcoded font points */
381 ULONG i;
382 for (i = 0; i < ARRAYSIZE(TrueTypePoints); ++i)
383 {
384 // _ultow(szFontSize, TrueTypePoints[i], 10);
385 StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", TrueTypePoints[i]);
386
387 /* Add the font size into the list, sorted by size value (string). Avoid any duplicates. */
388 if (SendMessageW(SizeList->hWndTTSizeList, CB_FINDSTRINGEXACT, 0, (LPARAM)szFontSize) == CB_ERR)
389 iItem = (UINT)SendMessageW(SizeList->hWndTTSizeList, CB_INSERTSTRING, -1, (LPARAM)szFontSize);
390 }
391
392 /* Stop the enumeration now */
393 return FALSE;
394 }
395}
#define FALSE
Definition: types.h:117
UINT BisectListSortedByValue(IN PLIST_CTL ListCtl, IN ULONG_PTR Value, OUT PUINT pValueItem OPTIONAL, IN BOOL BisectRightOrLeft)
Definition: utils.c:115
struct _FONTSIZE_LIST_CTL * PFONTSIZE_LIST_CTL
static const SHORT TrueTypePoints[]
Definition: font.c:27
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
LIST_CTL RasterSizeList
Definition: font.c:34
HWND hWndTTSizeList
Definition: font.c:35
HWND hWndList
Definition: console.h:93
uint32_t ULONG
Definition: typedefs.h:59
UINT_PTR WPARAM
Definition: windef.h:207
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109
#define MAKEWPARAM(l, h)
Definition: winuser.h:4009
#define CB_ERR
Definition: winuser.h:2435
#define LB_ERRSPACE
Definition: winuser.h:2433
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1940
#define LB_INSERTSTRING
Definition: winuser.h:2053
#define CB_INSERTSTRING
Definition: winuser.h:1957
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FontTypeChange().

◆ FaceNameList_Initialize()

static VOID FaceNameList_Initialize ( IN HWND  hWndList,
IN UINT  CodePage 
)
static

Definition at line 398 of file font.c.

401{
403 HDC hDC;
404 LOGFONTW lf;
405 INT idx;
406
407 /* Reset the face names list */
409
410 Param.hWndList = hWndList;
411 Param.CodePage = CodePage;
412
413 ZeroMemory(&lf, sizeof(lf));
414 lf.lfCharSet = DEFAULT_CHARSET; // CodePageToCharSet(CodePage);
415 // lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
416
417 hDC = GetDC(NULL);
420
422 if (idx != LB_ERR && idx != 0)
423 {
424 /* We have found some faces and filled the list, we are fine! */
425 return;
426 }
427
428 /* No fonts were found. Manually add default ones into the list. */
429 DPRINT1("The ideal console fonts were not found; manually add default ones.\n");
430
432#if 0
433 // TODO: insert only the *single* default TT font, that should
434 // be found in the TT font cache with the codepage number 0.
435 AddFontToList(hWndList, L"Lucida Console", TRUETYPE_FONTTYPE);
436#endif
437}
static HDC hDC
Definition: 3dtext.c:33
#define NULL
Definition: types.h:112
static BOOL CALLBACK EnumFaceNamesProc(IN PLOGFONTW lplf, IN PNEWTEXTMETRICW lpntm, IN DWORD FontType, IN LPARAM lParam)
Definition: font.c:321
unsigned int idx
Definition: utils.c:41
static HDC
Definition: imagelist.c:92
BYTE lfCharSet
Definition: dimm.idl:67
#define ZeroMemory
Definition: winbase.h:1712
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
FARPROC FONTENUMPROCW
Definition: wingdi.h:2897
#define DEFAULT_CHARSET
Definition: wingdi.h:384
#define RASTER_FONTTYPE
Definition: wingdi.h:1107
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define LB_GETCOUNT
Definition: winuser.h:2038
#define LB_RESETCONTENT
Definition: winuser.h:2055
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by FontProc().

◆ FaceNameList_SelectFont()

static VOID FaceNameList_SelectFont ( IN HWND  hDlg,
IN HWND  hWndList,
IN PFONTSIZE_LIST_CTL  SizeList,
IN LPCWSTR  FaceName,
IN ULONG  FontFamily,
IN ULONG  FontWeight,
IN COORD  FontSize 
)
static

Definition at line 440 of file font.c.

448{
449 INT iItem;
450
451 iItem = (INT)SendMessageW(hWndList, LB_FINDSTRINGEXACT, 0, (LPARAM)FaceName);
452 if (iItem == LB_ERR)
453 iItem = (INT)SendMessageW(hWndList, LB_FINDSTRINGEXACT, 0, (LPARAM)L"Terminal");
454 if (iItem == LB_ERR)
455 iItem = 0;
457
458 if (FontWeight >= FW_BOLD)
460 else
462
463 /* Select the current font size */
464 /*
465 * Format:
466 * Width = FontSize.X = LOWORD(FontSize);
467 * Height = FontSize.Y = HIWORD(FontSize);
468 */
469 SizeList->CurrentRasterSize = MAKELONG(FontSize.X, FontSize.Y);
470 SizeList->CurrentTTSize = FontSize.Y;
471 // FontSizeList_SelectFontSize(SizeList, SizeList->CurrentRasterSize);
472
473 // return iItem;
474}
#define IDC_CHECK_BOLD_FONTS
Definition: resource.h:38
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define FW_BOLD
Definition: wingdi.h:378
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define LB_SETCURSEL
Definition: winuser.h:2063
#define BST_CHECKED
Definition: winuser.h:197

Referenced by FontProc().

◆ FontProc()

INT_PTR CALLBACK FontProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 725 of file font.c.

729{
730 PFONTSIZE_LIST_CTL SizeList;
731
733
734 switch (uMsg)
735 {
736 case WM_INITDIALOG:
737 {
738 SizeList = (PFONTSIZE_LIST_CTL)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*SizeList));
739 if (!SizeList)
740 {
741 EndDialog(hDlg, 0);
742 return (INT_PTR)TRUE;
743 }
748 SizeList->bIsTTSizeDirty = FALSE;
749 SetWindowLongPtrW(hDlg, DWLP_USER, (LONG_PTR)SizeList);
750
751 /* By default show the raster font size list */
752 SizeList->UseRasterOrTTList = TRUE;
753
754 /* By default show the font sizes in pixel units */
756 SizeList->TTSizePixelUnit = TRUE;
757
758 UpdateFontSizeList(hDlg, SizeList);
759
760 DPRINT1("ConInfo->FaceName = '%S'\n", ConInfo->FaceName);
761
762 /* Face names list and current font selection will be done during PSN_SETACTIVE notification */
763 // CurrentCodePage = INVALID_CP;
764
765 return TRUE;
766 }
767
768 case WM_DESTROY:
769 {
770 if (SizeList)
771 HeapFree(GetProcessHeap(), 0, SizeList);
772 return (INT_PTR)TRUE;
773 }
774
775 case WM_DRAWITEM:
776 {
778
779 if (drawItem->CtlID == IDC_STATIC_SELECT_FONT_PREVIEW)
780 PaintText(drawItem, ConInfo, Screen);
781
782 return TRUE;
783 }
784
785 case WM_DISPLAYCHANGE:
786 {
787 /* Retransmit to the preview window */
789 WM_DISPLAYCHANGE, wParam, lParam);
790 break;
791 }
792
793 case WM_FONTCHANGE:
794 {
795 /* The pool of font resources has changed, re-enumerate the fonts */
796 HWND hFontList = GetDlgItem(hDlg, IDC_LBOX_FONTTYPE);
797
798 /* Initialize the font list */
800
801 /* Select the current font */
802 FaceNameList_SelectFont(hDlg, hFontList,
803 SizeList,
808
809 /* Refresh everything */
810 FontTypeChange(hDlg, SizeList, ConInfo);
811 break;
812 }
813
814 case WM_NOTIFY:
815 {
816 switch (((LPNMHDR)lParam)->code)
817 {
818 case PSN_APPLY:
819 {
820 ApplyConsoleInfo(hDlg);
821 return TRUE;
822 }
823
824 case PSN_SETACTIVE:
825 {
826 /* Check whether the current code page has changed.
827 * If so, re-enumerate the fonts. */
829 {
830 HWND hFontList;
831
832 /* Save the new code page */
834
835 hFontList = GetDlgItem(hDlg, IDC_LBOX_FONTTYPE);
836
837 /* Initialize the font list */
839
840 /* Select the current font */
841 FaceNameList_SelectFont(hDlg, hFontList,
842 SizeList,
847
848 /* Refresh everything */
849 FontTypeChange(hDlg, SizeList, ConInfo);
850 }
851
852 /* Fall back to default behaviour */
853 break;
854 }
855 }
856
857 break;
858 }
859
860 case WM_COMMAND:
861 {
862 if (HIWORD(wParam) == LBN_SELCHANGE /* || CBN_SELCHANGE */)
863 {
864 switch (LOWORD(wParam))
865 {
867 {
868 /* Change the property sheet state only if the font has really changed */
869 if (FontTypeChange(hDlg, SizeList, ConInfo))
870 PropSheet_Changed(GetParent(hDlg), hDlg);
871 break;
872 }
873
876 {
877 /* Change the property sheet state only if the font has really changed */
878 if (FontSizeChange(hDlg, SizeList, ConInfo))
879 PropSheet_Changed(GetParent(hDlg), hDlg);
880 break;
881 }
882 }
883 }
884 /* NOTE: CBN_EDITUPDATE is sent first, and is followed by CBN_EDITCHANGE */
886 {
887 ULONG FontSize;
888 PWCHAR pszNext = NULL;
889 WCHAR szFontSize[100];
890 WCHAR szMessage[260];
891
892 /* Read the ComboBox edit string, as the user has entered a custom size */
893 GetWindowTextW(SizeList->hWndTTSizeList, szFontSize, ARRAYSIZE(szFontSize));
894
895 /* Validate the font size */
896 FontSize = wcstoul(szFontSize, &pszNext, 10);
897 if ((FontSize == 0) || (*pszNext))
898 {
899 // FIXME: Localize!
900 StringCchPrintfW(szMessage, ARRAYSIZE(szMessage), L"\"%s\" is not a valid font size.", szFontSize);
901 MessageBoxW(hDlg, szMessage, L"Error", MB_ICONINFORMATION | MB_OK);
902 }
903 SizeList->bIsTTSizeDirty = TRUE;
904 }
906 {
907 /* Change the property sheet state only if the font has really changed */
908 if (FontSizeChange(hDlg, SizeList, ConInfo))
909 PropSheet_Changed(GetParent(hDlg), hDlg);
910 }
911 else
912 if (HIWORD(wParam) == BN_CLICKED)
913 {
914 switch (LOWORD(wParam))
915 {
917 {
920 else
922
923 FontTypeChange(hDlg, SizeList, ConInfo);
924 PropSheet_Changed(GetParent(hDlg), hDlg);
925 break;
926 }
927
930 {
932
933 /* The call is valid only for TrueType fonts */
935 break;
936
937 /* Change the property sheet state only if the font has really changed */
938 if (FontSizeChange(hDlg, SizeList, ConInfo))
939 PropSheet_Changed(GetParent(hDlg), hDlg);
940 break;
941 }
942 }
943 }
944
945 break;
946 }
947
948 default:
949 break;
950 }
951
952 return FALSE;
953}
WPARAM wParam
Definition: combotst.c:138
PCONSOLE_STATE_INFO ConInfo
Definition: console.c:23
VOID ApplyConsoleInfo(HWND hwndDlg)
Definition: console.c:88
@ Screen
Definition: console.h:34
VOID PaintText(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo, IN TEXT_TYPE TextMode)
Definition: layout.c:471
static DWORD CurrentFontType
Definition: font.c:45
static VOID FaceNameList_Initialize(IN HWND hWndList, IN UINT CodePage)
Definition: font.c:398
static UINT CurrentCodePage
Definition: font.c:48
static VOID FaceNameList_SelectFont(IN HWND hDlg, IN HWND hWndList, IN PFONTSIZE_LIST_CTL SizeList, IN LPCWSTR FaceName, IN ULONG FontFamily, IN ULONG FontWeight, IN COORD FontSize)
Definition: font.c:440
static VOID UpdateFontSizeList(IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList)
Definition: font.c:477
static BOOL FontSizeChange(IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList, IN OUT PCONSOLE_STATE_INFO pConInfo)
Definition: font.c:656
static ULONG_PTR RasterSizeList_GetData(IN PLIST_CTL ListCtl, IN INT Index)
Definition: font.c:91
static BOOL FontTypeChange(IN HWND hDlg, IN PFONTSIZE_LIST_CTL SizeList, IN OUT PCONSOLE_STATE_INFO pConInfo)
Definition: font.c:542
static INT RasterSizeList_GetCount(IN PLIST_CTL ListCtl)
Definition: font.c:83
#define IDC_RADIO_PIXEL_UNIT
Definition: resource.h:44
#define IDC_LBOX_FONTTYPE
Definition: resource.h:47
#define IDC_STATIC_FONT_WINDOW_PREVIEW
Definition: resource.h:46
#define IDC_CBOX_FONTSIZE
Definition: resource.h:43
#define IDC_RADIO_POINT_UNIT
Definition: resource.h:45
#define IDC_STATIC_SELECT_FONT_PREVIEW
Definition: resource.h:39
#define IDC_LBOX_FONTSIZE
Definition: resource.h:42
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_SETACTIVE
Definition: prsht.h:115
#define WM_NOTIFY
Definition: richedit.h:61
WCHAR FaceName[LF_FACESIZE]
Definition: settings.h:39
BOOL UseRasterOrTTList
Definition: font.c:37
BOOL bIsTTSizeDirty
Definition: font.c:36
BOOL TTSizePixelUnit
Definition: font.c:38
PLIST_GETCOUNT GetCount
Definition: console.h:94
PLIST_GETDATA GetData
Definition: console.h:95
Definition: inflate.c:139
int32_t INT_PTR
Definition: typedefs.h:64
uint16_t * PWCHAR
Definition: typedefs.h:56
#define HIWORD(l)
Definition: typedefs.h:247
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
#define FW_NORMAL
Definition: wingdi.h:373
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define DWLP_USER
Definition: winuser.h:872
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define CBN_EDITUPDATE
Definition: winuser.h:1976
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1645
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define CBN_KILLFOCUS
Definition: winuser.h:1978
#define MB_OK
Definition: winuser.h:790
HWND WINAPI GetParent(_In_ HWND)
#define LBN_SELCHANGE
Definition: winuser.h:2075
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define MB_ICONINFORMATION
Definition: winuser.h:802
#define BN_CLICKED
Definition: winuser.h:1925
#define WM_DESTROY
Definition: winuser.h:1609
#define WM_FONTCHANGE
Definition: winuser.h:1633
#define SetWindowLongPtrW
Definition: winuser.h:5355
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by InitApplet().

◆ FontSizeChange()

static BOOL FontSizeChange ( IN HWND  hDlg,
IN PFONTSIZE_LIST_CTL  SizeList,
IN OUT PCONSOLE_STATE_INFO  pConInfo 
)
static

Definition at line 656 of file font.c.

660{
661 LONG FontSize;
663 HFONT hFont;
664 WCHAR szFontSize[100];
665
666 /*
667 * Retrieve the current selected font size.
668 * - If SizeList->UseRasterOrTTList is TRUE, or if it is FALSE but
669 * if SizeList->TTSizePixelUnit is TRUE, then the font size is in pixels;
670 * - If SizeList->TTSizePixelUnit is FALSE, then the font size is in points.
671 */
672 FontSize = FontSizeList_GetSelectedFontSize(SizeList);
673 if (FontSize == 0)
674 return FALSE; // We have got an invalid font size...
675
676 /*
677 * For TrueType fonts we set the requested width to zero
678 * so as to obtain a default aspect-ratio width.
679 */
680 CharHeight = (UINT)(SizeList->UseRasterOrTTList ? HIWORD(FontSize) : FontSize);
681 CharWidth = (UINT)(SizeList->UseRasterOrTTList ? LOWORD(FontSize) : 0);
682
684 if (!hFont)
685 {
686 DPRINT1("FontSizeChange: CreateConsoleFont2() failed\n");
687 return FALSE;
688 }
689
690 /* Retrieve the real character size in pixels */
691 GetFontCellSize(NULL, hFont, &CharHeight, &CharWidth);
692
693 /*
694 * Update the font preview as well, and store the font handle. It will be
695 * freed at later update or when the font preview is refreshed or reset.
696 * For TrueType fonts, the preview will show the actual character width.
697 */
699
700 /*
701 * Format:
702 * Width = FontSize.X = LOWORD(FontSize);
703 * Height = FontSize.Y = HIWORD(FontSize);
704 */
705 pConInfo->FontSize.X = (SHORT)(SizeList->UseRasterOrTTList ? CharWidth : 0);
706 pConInfo->FontSize.Y = (SHORT)CharHeight;
707
708 DPRINT("pConInfo->FontSize = (%d x %d) ; (CharWidth x CharHeight) = (%d x %d)\n",
709 pConInfo->FontSize.X, pConInfo->FontSize.Y, CharWidth, CharHeight);
710
713
714 StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", CharWidth);
715 SetDlgItemText(hDlg, IDC_FONT_SIZE_X, szFontSize);
716 StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", CharHeight);
717 SetDlgItemText(hDlg, IDC_FONT_SIZE_Y, szFontSize);
718
719 return TRUE;
720}
HFONT hFont
Definition: main.c:53
static int CharWidth
Definition: carets.c:7
static int CharHeight
Definition: carets.c:8
FONT_PREVIEW FontPreview
Definition: font.c:21
static LONG FontSizeList_GetSelectedFontSize(IN PFONTSIZE_LIST_CTL SizeList)
Definition: font.c:199
VOID UpdateFontPreview(IN FONT_PREVIEW *Preview, IN HFONT hFont, IN UINT CharWidth, IN UINT CharHeight)
Definition: font.c:69
#define IDC_FONT_SIZE_X
Definition: resource.h:40
#define IDC_FONT_SIZE_Y
Definition: resource.h:41
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:73
HFONT CreateConsoleFont2(_In_ LONG Height, _In_opt_ LONG Width, _Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
A wrapper for CreateConsoleFontEx().
Definition: font.c:609
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SetDlgItemText
Definition: winuser.h:5858

Referenced by FontProc(), and FontTypeChange().

◆ FontSizeList_GetSelectedFontSize()

static LONG FontSizeList_GetSelectedFontSize ( IN PFONTSIZE_LIST_CTL  SizeList)
static

Definition at line 199 of file font.c.

201{
202 INT nSel;
203 LONG FontSize;
204 PWCHAR pszNext = NULL;
205 WCHAR szFontSize[100];
206
207 if (SizeList->UseRasterOrTTList)
208 {
209 /* Raster font size (in pixels) */
210
211 nSel = (INT)SendMessageW(SizeList->RasterSizeList.hWndList, LB_GETCURSEL, 0, 0);
212 if (nSel == LB_ERR) return 0;
213
214 FontSize = (LONG)SizeList->RasterSizeList.GetData(&SizeList->RasterSizeList, nSel);
215 if (FontSize == LB_ERR) return 0;
216
217 SizeList->CurrentRasterSize = FontSize;
218 }
219 else
220 {
221 /* TrueType font size (in pixels or points) */
222
223 if (!SizeList->bIsTTSizeDirty)
224 {
225 /*
226 * The user just selected an existing size, read the ComboBox selection.
227 *
228 * See: https://support.microsoft.com/en-us/help/66365/how-to-process-a-cbn-selchange-notification-message
229 * for more details.
230 */
231 INT Length;
232
233 nSel = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_GETCURSEL, 0, 0);
234 if (nSel == CB_ERR) return 0;
235
236 Length = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_GETLBTEXTLEN, nSel, 0);
237 ASSERT((Length != LB_ERR) && (Length < ARRAYSIZE(szFontSize)));
238
239 Length = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_GETLBTEXT, nSel, (LPARAM)szFontSize);
240 ASSERT((Length != LB_ERR) && (Length < ARRAYSIZE(szFontSize)));
241 szFontSize[Length] = L'\0';
242
243 /* Validate the font size */
244 FontSize = wcstoul(szFontSize, &pszNext, 10);
245 if ((FontSize == 0) || (*pszNext))
246 return 0;
247 }
248 else
249 {
250 /* Read the ComboBox edit string, as the user has entered a custom size */
251 // ComboBox_GetText(...)
252 GetWindowTextW(SizeList->hWndTTSizeList, szFontSize, ARRAYSIZE(szFontSize));
253
254 /* Validate the font size */
255 FontSize = wcstoul(szFontSize, &pszNext, 10);
256 if ((FontSize == 0) || (*pszNext))
257 return 0;
258
259 /* Find if the font size already exists in the list; if not, add it */
260 nSel = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_FINDSTRINGEXACT, 0, (LPARAM)szFontSize);
261 if (nSel == CB_ERR)
262 {
263 nSel = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_ADDSTRING, -1, (LPARAM)szFontSize);
265 //SetWindowTextW(SizeList->hWndTTSizeList, szFontSize);
266 //SizeList->bIsTTSizeDirty = TRUE;
267 }
268 SendMessageW(SizeList->hWndTTSizeList, CB_SETCURSEL, (WPARAM)nSel, 0);
269 }
270
271 SizeList->bIsTTSizeDirty = FALSE;
272
273 SizeList->CurrentTTSize = FontSize;
274
275 /*
276 * If the font size is given in points, instead of pixels,
277 * convert it into logical size.
278 */
279 if (!SizeList->TTSizePixelUnit)
280 FontSize = -PointSizeToLogicalSize(NULL, FontSize);
281 }
282
283 return FontSize;
284}
INT PointSizeToLogicalSize(IN HDC hDC OPTIONAL, IN INT PointSize)
Definition: font.c:120
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define CB_GETLBTEXTLEN
Definition: winuser.h:1953
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define CB_SETCURSEL
Definition: winuser.h:1961
#define CB_ADDSTRING
Definition: winuser.h:1936
#define LB_GETCURSEL
Definition: winuser.h:2039
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by FontSizeChange().

◆ FontSizeList_SelectFontSize()

static VOID FontSizeList_SelectFontSize ( IN PFONTSIZE_LIST_CTL  SizeList,
IN ULONG  FontSize 
)
static

Definition at line 140 of file font.c.

143{
144 INT nSel;
145 WCHAR szFontSize[100];
146
147 //
148 // FIXME: Check whether FontSize == 0
149 // (or in the case of raster font maybe, whether HIWORD(FontSize) == Height == 0) ??
150 //
151
152 /* Find and select the best font size in the list corresponding to the current size */
153 if (SizeList->UseRasterOrTTList)
154 {
155 INT idx;
156
157 /* Raster font size (in pixels) */
158 SizeList->CurrentRasterSize = FontSize;
159
160 nSel = BisectListSortedByValue(&SizeList->RasterSizeList, FontSize, NULL, FALSE);
161 idx = (INT)SendMessageW(SizeList->RasterSizeList.hWndList, LB_GETCOUNT, 0, 0);
162 if (nSel == LB_ERR)
163 {
164 /* Not found, select the first element of the list */
165 nSel = 0;
166 }
167 else if (nSel >= idx)
168 {
169 /*
170 * We got an index beyond the end of the list (as per Bisect* functionality),
171 * so instead, select the last element of the list.
172 */
173 nSel = idx - 1;
174 }
175 SendMessageW(SizeList->RasterSizeList.hWndList, LB_SETCURSEL, (WPARAM)nSel, 0);
176 }
177 else
178 {
179 /* TrueType font size (in pixels or points) */
180 SizeList->CurrentTTSize = FontSize;
181
182 // _ultow(szFontSize, FontSize, 10);
183 StringCchPrintfW(szFontSize, ARRAYSIZE(szFontSize), L"%d", FontSize);
184
185 /* Find the font size in the list, or add it both in the ComboBox list, sorted by size value (string), and its edit box */
186 nSel = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_FINDSTRINGEXACT, 0, (LPARAM)szFontSize);
187 if (nSel == CB_ERR)
188 {
189 nSel = (INT)SendMessageW(SizeList->hWndTTSizeList, CB_ADDSTRING, -1, (LPARAM)szFontSize);
190 // ComboBox_SetText(...)
191 SetWindowTextW(SizeList->hWndTTSizeList, szFontSize);
192 SizeList->bIsTTSizeDirty = TRUE;
193 }
194 SendMessageW(SizeList->hWndTTSizeList, CB_SETCURSEL, (WPARAM)nSel, 0);
195 }
196}
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

Referenced by FontTypeChange().

◆ FontTypeChange()

static BOOL FontTypeChange ( IN HWND  hDlg,
IN PFONTSIZE_LIST_CTL  SizeList,
IN OUT PCONSOLE_STATE_INFO  pConInfo 
)
static

Definition at line 542 of file font.c.

546{
547 HWND hFontList = GetDlgItem(hDlg, IDC_LBOX_FONTTYPE);
548 INT Length, nSel;
549 LPWSTR FaceName;
550 DWORD FontType;
551 LPCWSTR FontGrpBoxLabelTpl = NULL;
552 WCHAR FontGrpBoxLabel[260];
553
554 nSel = (INT)SendMessageW(hFontList, LB_GETCURSEL, 0, 0);
555 if (nSel == LB_ERR) return FALSE;
556
557 /*
558 * This is disabled, because there can be external parameters
559 * that may have changed (e.g. ConInfo->FontWeight, code page, ...)
560 * and that we don't control here, and that need a font refresh.
561 */
562#if 0
563 /* Check whether the selection has changed */
564 if (nSel == CurrentSelFont)
565 return FALSE;
566#endif
567
568 Length = (INT)SendMessageW(hFontList, LB_GETTEXTLEN, nSel, 0);
569 if (Length == LB_ERR) return FALSE;
570
571 FaceName = HeapAlloc(GetProcessHeap(),
573 (Length + 1) * sizeof(WCHAR));
574 if (FaceName == NULL) return FALSE;
575
576 Length = (INT)SendMessageW(hFontList, LB_GETTEXT, nSel, (LPARAM)FaceName);
577 ASSERT(Length != LB_ERR);
578 FaceName[Length] = L'\0';
579
580 StringCchCopyW(pConInfo->FaceName, ARRAYSIZE(pConInfo->FaceName), FaceName);
581 DPRINT("pConInfo->FaceName = '%S'\n", pConInfo->FaceName);
582
583 /*
584 * Retrieve the read-only font group box label string template,
585 * and set the group box label to the name of the selected font.
586 */
587 Length = LoadStringW(hApplet, IDS_GROUPBOX_FONT_NAME, (LPWSTR)&FontGrpBoxLabelTpl, 0);
588 if (FontGrpBoxLabelTpl && Length > 0)
589 {
590 StringCchCopyNW(FontGrpBoxLabel, ARRAYSIZE(FontGrpBoxLabel), FontGrpBoxLabelTpl, Length);
591 StringCchCatW(FontGrpBoxLabel, ARRAYSIZE(FontGrpBoxLabel), FaceName);
592 SetDlgItemTextW(hDlg, IDC_GROUPBOX_FONT_NAME, FontGrpBoxLabel);
593 }
594
595 HeapFree(GetProcessHeap(), 0, FaceName);
596
597 /*
598 * Reset the font size list, only:
599 * - if we have changed the type of font, or
600 * - if the font type is the same and is RASTER but the font has changed.
601 * Otherwise, if the font type is not RASTER and has not changed,
602 * we always display the TrueType default sizes and we don't need to
603 * recreate the list when we change between different TrueType fonts.
604 */
605 FontType = (DWORD)SendMessageW(hFontList, LB_GETITEMDATA, nSel, 0);
606 if (FontType != LB_ERR)
607 {
608 SizeList->UseRasterOrTTList = (FontType == RASTER_FONTTYPE);
609
610 /* Display the correct font size list (if needed) */
611 if (CurrentFontType != FontType)
612 UpdateFontSizeList(hDlg, SizeList);
613
614 /* Enumerate the available sizes for the selected font */
615 if ((CurrentFontType != FontType) ||
616 (FontType == RASTER_FONTTYPE && CurrentSelFont != nSel))
617 {
618 LOGFONTW lf;
619 HDC hDC;
620
621 if (SizeList->UseRasterOrTTList)
622 SendMessageW(SizeList->RasterSizeList.hWndList, LB_RESETCONTENT, 0, 0);
623 else
624 SendMessageW(SizeList->hWndTTSizeList, CB_RESETCONTENT, 0, 0);
625
626 ZeroMemory(&lf, sizeof(lf));
627 lf.lfCharSet = DEFAULT_CHARSET; // CodePageToCharSet(pConInfo->CodePage);
628 // lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
629 StringCchCopyW(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), pConInfo->FaceName);
630
631 hDC = GetDC(NULL);
634
635 /* Re-select the current font size */
636 if (SizeList->UseRasterOrTTList)
637 FontSizeList_SelectFontSize(SizeList, SizeList->CurrentRasterSize);
638 else
639 FontSizeList_SelectFontSize(SizeList, SizeList->CurrentTTSize);
640 }
641 }
642 else
643 {
644 /* We failed, display the raster fonts size list */
645 SizeList->UseRasterOrTTList = TRUE;
646 UpdateFontSizeList(hDlg, SizeList);
647 }
648 CurrentFontType = FontType;
649 CurrentSelFont = nSel;
650
651 FontSizeChange(hDlg, SizeList, pConInfo);
652 return TRUE;
653}
HINSTANCE hApplet
Definition: access.c:17
static BOOL CALLBACK EnumFontSizesProc(IN PLOGFONTW lplf, IN PNEWTEXTMETRICW lpntm, IN DWORD FontType, IN LPARAM lParam)
Definition: font.c:340
static VOID FontSizeList_SelectFontSize(IN PFONTSIZE_LIST_CTL SizeList, IN ULONG FontSize)
Definition: font.c:140
static INT CurrentSelFont
Definition: font.c:44
#define IDS_GROUPBOX_FONT_NAME
Definition: resource.h:100
#define IDC_GROUPBOX_FONT_NAME
Definition: resource.h:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DWORD
Definition: nt_native.h:44
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
#define LB_GETITEMDATA
Definition: winuser.h:2041
#define LB_GETTEXT
Definition: winuser.h:2049
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define CB_RESETCONTENT
Definition: winuser.h:1959
#define LB_GETTEXTLEN
Definition: winuser.h:2050
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by FontProc().

◆ LogicalSizeToPointSize()

INT LogicalSizeToPointSize ( IN HDC hDC  OPTIONAL,
IN UINT  LogicalSize 
)

Definition at line 100 of file font.c.

103{
104 INT PointSize;
105 HDC hOrgDC = hDC;
106
107 if (!hDC)
108 hDC = GetDC(NULL);
109
110 // LogicalSize = tm.tmHeight - tm.tmInternalLeading;
111 PointSize = MulDiv(LogicalSize, 72, GetDeviceCaps(hDC, LOGPIXELSY));
112
113 if (!hOrgDC)
115
116 return PointSize;
117}
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719

◆ PointSizeToLogicalSize()

INT PointSizeToLogicalSize ( IN HDC hDC  OPTIONAL,
IN INT  PointSize 
)

Definition at line 120 of file font.c.

123{
124 INT LogicalSize;
125 HDC hOrgDC = hDC;
126
127 if (!hDC)
128 hDC = GetDC(NULL);
129
130 LogicalSize = MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
131
132 if (!hOrgDC)
134
135 return LogicalSize;
136}

Referenced by FontSizeList_GetSelectedFontSize().

◆ RasterSizeList_GetCount()

static INT RasterSizeList_GetCount ( IN PLIST_CTL  ListCtl)
static

Definition at line 83 of file font.c.

85{
86 return (INT)SendMessageW(ListCtl->hWndList, LB_GETCOUNT, 0, 0);
87}

Referenced by FontProc().

◆ RasterSizeList_GetData()

static ULONG_PTR RasterSizeList_GetData ( IN PLIST_CTL  ListCtl,
IN INT  Index 
)
static

Definition at line 91 of file font.c.

94{
95 return (ULONG_PTR)SendMessageW(ListCtl->hWndList, LB_GETITEMDATA, (WPARAM)Index, 0);
96}
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by FontProc().

◆ RefreshFontPreview()

VOID RefreshFontPreview ( IN FONT_PREVIEW Preview,
IN PCONSOLE_STATE_INFO  pConInfo 
)

Definition at line 52 of file font.c.

55{
56 HFONT hFont = CreateConsoleFont(pConInfo);
57 if (!hFont)
58 {
59 DPRINT1("RefreshFontPreview: CreateConsoleFont() failed\n");
60 return;
61 }
62
63 if (Preview->hFont) DeleteObject(Preview->hFont);
64 Preview->hFont = hFont;
65 GetFontCellSize(NULL, hFont, &Preview->CharHeight, &Preview->CharWidth);
66}
pKey DeleteObject()
HFONT CreateConsoleFont(_Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
A wrapper for CreateConsoleFontEx().
Definition: font.c:653

Referenced by InitApplet(), PaintText(), and WinPrev_OnDraw().

◆ UpdateFontPreview()

VOID UpdateFontPreview ( IN FONT_PREVIEW Preview,
IN HFONT  hFont,
IN UINT  CharWidth,
IN UINT  CharHeight 
)

Definition at line 69 of file font.c.

74{
75 if (Preview->hFont) DeleteObject(Preview->hFont);
76 Preview->hFont = hFont;
77 Preview->CharWidth = CharWidth;
78 Preview->CharHeight = CharHeight;
79}

Referenced by FontSizeChange().

◆ UpdateFontSizeList()

static VOID UpdateFontSizeList ( IN HWND  hDlg,
IN PFONTSIZE_LIST_CTL  SizeList 
)
static

Definition at line 477 of file font.c.

480{
481 HWND hDlgItem;
482
483 if (SizeList->UseRasterOrTTList)
484 {
485 /*
486 * Raster font: show the Raster size list, and
487 * hide the TrueType size list and the units.
488 */
489
490 // EnableDlgItem(hDlg, IDC_CHECK_BOLD_FONTS, FALSE);
491
492 hDlgItem = GetDlgItem(hDlg, IDC_RADIO_PIXEL_UNIT);
493 ShowWindow(hDlgItem, SW_HIDE);
494 EnableWindow(hDlgItem, FALSE);
495
496 hDlgItem = GetDlgItem(hDlg, IDC_RADIO_POINT_UNIT);
497 ShowWindow(hDlgItem, SW_HIDE);
498 EnableWindow(hDlgItem, FALSE);
499
500 hDlgItem = SizeList->hWndTTSizeList;
501 ShowWindow(hDlgItem, SW_HIDE);
502 EnableWindow(hDlgItem, FALSE);
503
504 hDlgItem = SizeList->RasterSizeList.hWndList;
505 EnableWindow(hDlgItem, TRUE);
506 ShowWindow(hDlgItem, SW_SHOW);
507 }
508 else
509 {
510 /*
511 * TrueType font: show the TrueType size list
512 * and the units, and hide the Raster size list.
513 */
514
515 // EnableDlgItem(hDlg, IDC_CHECK_BOLD_FONTS, TRUE);
516
517 hDlgItem = SizeList->RasterSizeList.hWndList;
518 ShowWindow(hDlgItem, SW_HIDE);
519 EnableWindow(hDlgItem, FALSE);
520
521 hDlgItem = SizeList->hWndTTSizeList;
522 EnableWindow(hDlgItem, TRUE);
523 ShowWindow(hDlgItem, SW_SHOW);
524
525 hDlgItem = GetDlgItem(hDlg, IDC_RADIO_PIXEL_UNIT);
526 EnableWindow(hDlgItem, TRUE);
527 ShowWindow(hDlgItem, SW_SHOW);
528
529 hDlgItem = GetDlgItem(hDlg, IDC_RADIO_POINT_UNIT);
530 EnableWindow(hDlgItem, TRUE);
531 ShowWindow(hDlgItem, SW_SHOW);
532 }
533}
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define SW_SHOW
Definition: winuser.h:775

Referenced by FontProc(), and FontTypeChange().

Variable Documentation

◆ CurrentCodePage

UINT CurrentCodePage = INVALID_CP
static

Definition at line 48 of file font.c.

Referenced by BuildCodePageList(), and FontProc().

◆ CurrentFontType

DWORD CurrentFontType = (DWORD)-1
static

Definition at line 45 of file font.c.

Referenced by FontProc(), and FontTypeChange().

◆ CurrentSelFont

INT CurrentSelFont = LB_ERR
static

Definition at line 44 of file font.c.

Referenced by FontTypeChange().

◆ FontPreview

FONT_PREVIEW FontPreview = {NULL, 0, 0}

Definition at line 21 of file font.c.

Referenced by FontSizeChange(), InitApplet(), OptionsProc(), PaintText(), and WinPrev_OnDraw().

◆ TrueTypePoints

const SHORT TrueTypePoints[]
static
Initial value:
=
{
5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
}

Definition at line 27 of file font.c.

Referenced by EnumFontSizesProc().