Author: hbelusca
Date: Thu Aug 14 20:10:00 2014
New Revision: 63885
URL:
http://svn.reactos.org/svn/reactos?rev=63885&view=rev
Log:
[KERNEL32]
OpenConsoleW was implemented :P
[CONSOLE.CPL][CONSRV]
Create all the fonts needed at console startup, and then just select what's needed
when fonts attributes need to be changed at run-time.
[CONSOLE.CPL][CONSRV]
- HACKFIX: Temporary use FW_NORMAL instead of FW_DONTCARE as default font weight (in
ReactOS, FW_DONTCARE makes fonts bold by default, instead of normal)
- Use bold fonts instead of the underlined ones for underlined fonts in the terminal.
Timo, FIX THE FONTS !!!!!!!!!! :P
CORE-8439 #comment Should be fixed in revision 63885.
Modified:
branches/condrv_restructure/dll/cpl/console/console.c
branches/condrv_restructure/dll/cpl/console/layout.c
branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/text.c
Modified: branches/condrv_restructure/dll/cpl/console/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/cpl/cons…
==============================================================================
--- branches/condrv_restructure/dll/cpl/console/console.c [iso-8859-1] (original)
+++ branches/condrv_restructure/dll/cpl/console/console.c [iso-8859-1] Thu Aug 14 20:10:00
2014
@@ -117,7 +117,8 @@
GuiInfo->FontFamily = FF_DONTCARE;
GuiInfo->FontSize.X = 0;
GuiInfo->FontSize.Y = 0;
- GuiInfo->FontWeight = FW_DONTCARE;
+ GuiInfo->FontWeight = FW_NORMAL; // HACK: !!
+ // GuiInfo->FontWeight = FW_DONTCARE;
GuiInfo->FullScreen = FALSE;
GuiInfo->ShowWindow = SW_SHOWNORMAL;
Modified: branches/condrv_restructure/dll/cpl/console/layout.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/cpl/cons…
==============================================================================
--- branches/condrv_restructure/dll/cpl/console/layout.c [iso-8859-1] (original)
+++ branches/condrv_restructure/dll/cpl/console/layout.c [iso-8859-1] Thu Aug 14 20:10:00
2014
@@ -121,7 +121,7 @@
if (!hBrush) return FALSE;
Font = CreateFontW(GuiInfo->FontSize.Y,
- 0, // GuiInfo->FontSize.X,
+ GuiInfo->FontSize.X,
0,
TA_BASELINE,
GuiInfo->FontWeight,
@@ -131,8 +131,8 @@
OEM_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | GuiInfo->FontFamily /* FF_DONTCARE */,
+ DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY
+ FIXED_PITCH | GuiInfo->FontFamily,
GuiInfo->FaceName);
if (Font == NULL)
{
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -561,7 +561,7 @@
/*
- * @unimplemented (Undocumented)
+ * @implemented (Undocumented)
*/
HANDLE
WINAPI
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -486,15 +486,166 @@
// to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
}
+
+VOID
+DeleteFonts(PGUI_CONSOLE_DATA GuiData)
+{
+ ULONG i;
+ for (i = 0; i < sizeof(GuiData->Font) / sizeof(GuiData->Font[0]); ++i)
+ {
+ if (GuiData->Font[i] != NULL) DeleteObject(GuiData->Font[i]);
+ GuiData->Font[i] = NULL;
+ }
+}
+
+static HFONT
+CreateDerivedFont(HFONT OrgFont,
+ // COORD FontSize,
+ ULONG FontWeight,
+ // BOOLEAN bItalic,
+ BOOLEAN bUnderline,
+ BOOLEAN bStrikeOut)
+{
+ LOGFONT lf;
+
+ /* Initialize the LOGFONT structure */
+ RtlZeroMemory(&lf, sizeof(lf));
+
+ /* Retrieve the details of the current font */
+ if (GetObject(OrgFont, sizeof(lf), &lf) == 0)
+ return NULL;
+
+ /* Change the font attributes */
+ // lf.lfHeight = FontSize.Y;
+ // lf.lfWidth = FontSize.X;
+ lf.lfWeight = FontWeight;
+ // lf.lfItalic = bItalic;
+ lf.lfUnderline = bUnderline;
+ lf.lfStrikeOut = bStrikeOut;
+
+ /* Build a new font */
+ return CreateFontIndirect(&lf);
+}
+
+BOOL
+InitFonts(PGUI_CONSOLE_DATA GuiData,
+ LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
+ ULONG FontFamily,
+ COORD FontSize,
+ ULONG FontWeight)
+{
+ HDC hDC;
+ HFONT OldFont, NewFont;
+ TEXTMETRICW Metrics;
+ SIZE CharSize;
+
+ /*
+ * Initialize a new NORMAL font and get its metrics.
+ */
+
+ NewFont = CreateFontW(FontSize.Y,
+ FontSize.X,
+ 0,
+ TA_BASELINE,
+ FontWeight,
+ FALSE,
+ FALSE,
+ FALSE,
+ OEM_CHARSET,
+ OUT_DEFAULT_PRECIS,
+ CLIP_DEFAULT_PRECIS,
+ DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ;
ANTIALIASED_QUALITY
+ FIXED_PITCH | FontFamily,
+ FaceName);
+ if (NewFont == NULL)
+ {
+ DPRINT1("InitFonts: CreateFontW failed\n");
+ return FALSE;
+ }
+
+ hDC = GetDC(GuiData->hWindow);
+ if (hDC == NULL)
+ {
+ DPRINT1("InitFonts: GetDC failed\n");
+ DeleteObject(NewFont);
+ return FALSE;
+ }
+
+ OldFont = SelectObject(hDC, NewFont);
+ if (OldFont == NULL)
+ {
+ DPRINT1("InitFonts: SelectObject failed\n");
+ ReleaseDC(GuiData->hWindow, hDC);
+ DeleteObject(NewFont);
+ return FALSE;
+ }
+
+ if (!GetTextMetricsW(hDC, &Metrics))
+ {
+ DPRINT1("InitFonts: GetTextMetrics failed\n");
+ SelectObject(hDC, OldFont);
+ ReleaseDC(GuiData->hWindow, hDC);
+ DeleteObject(NewFont);
+ return FALSE;
+ }
+ GuiData->CharWidth = Metrics.tmMaxCharWidth;
+ GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
+
+ /* Measure real char width more precisely if possible. */
+ if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
+ GuiData->CharWidth = CharSize.cx;
+
+ SelectObject(hDC, OldFont);
+ ReleaseDC(GuiData->hWindow, hDC);
+
+ /*
+ * Initialization succeeded.
+ */
+ // Delete all the old fonts first.
+ DeleteFonts(GuiData);
+ GuiData->Font[FONT_NORMAL] = NewFont;
+
+ /*
+ * Now build the other fonts (bold, underlined, mixed).
+ */
+ GuiData->Font[FONT_BOLD] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
+ FALSE,
+ FALSE);
+ GuiData->Font[FONT_UNDERLINE] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight,
+ TRUE,
+ FALSE);
+ GuiData->Font[FONT_BOLD | FONT_UNDERLINE] =
+ CreateDerivedFont(GuiData->Font[FONT_NORMAL],
+ FontWeight < FW_BOLD ? FW_BOLD : FontWeight,
+ TRUE,
+ FALSE);
+
+ /*
+ * Save the settings.
+ */
+ if (FaceName != GuiData->GuiInfo.FaceName)
+ {
+ SIZE_T Length = min(wcslen(FaceName) + 1, LF_FACESIZE); // wcsnlen
+ wcsncpy(GuiData->GuiInfo.FaceName, FaceName, LF_FACESIZE);
+ GuiData->GuiInfo.FaceName[Length] = L'\0'; // NULL-terminate
+ }
+ GuiData->GuiInfo.FontFamily = FontFamily;
+ GuiData->GuiInfo.FontSize = FontSize;
+ GuiData->GuiInfo.FontWeight = FontWeight;
+
+ return TRUE;
+}
+
+
static BOOL
OnNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
{
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
PCONSRV_CONSOLE Console;
- HDC hDC;
- HFONT OldFont;
- TEXTMETRICW Metrics;
- SIZE CharSize;
if (NULL == GuiData)
{
@@ -506,67 +657,18 @@
GuiData->hWindow = hWnd;
- GuiData->Font = CreateFontW(GuiData->GuiInfo.FontSize.Y,
- 0, // GuiData->GuiInfo.FontSize.X,
- 0,
- TA_BASELINE,
- GuiData->GuiInfo.FontWeight,
- FALSE,
- FALSE,
- FALSE,
- OEM_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | GuiData->GuiInfo.FontFamily /*
FF_DONTCARE */,
- GuiData->GuiInfo.FaceName);
-
- if (NULL == GuiData->Font)
- {
- DPRINT1("GuiConsoleNcCreate: CreateFont failed\n");
+ /* Initialize the fonts */
+ if (!InitFonts(GuiData,
+ GuiData->GuiInfo.FaceName,
+ GuiData->GuiInfo.FontFamily,
+ GuiData->GuiInfo.FontSize,
+ GuiData->GuiInfo.FontWeight))
+ {
+ DPRINT1("GuiConsoleNcCreate: InitFonts failed\n");
GuiData->hWindow = NULL;
SetEvent(GuiData->hGuiInitEvent);
return FALSE;
}
- hDC = GetDC(GuiData->hWindow);
- if (NULL == hDC)
- {
- DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
- return FALSE;
- }
- OldFont = SelectObject(hDC, GuiData->Font);
- if (NULL == OldFont)
- {
- DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
- return FALSE;
- }
- if (!GetTextMetricsW(hDC, &Metrics))
- {
- DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
- SelectObject(hDC, OldFont);
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(GuiData->Font);
- GuiData->hWindow = NULL;
- SetEvent(GuiData->hGuiInitEvent);
- return FALSE;
- }
- GuiData->CharWidth = Metrics.tmMaxCharWidth;
- GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
-
- /* Measure real char width more precisely if possible. */
- if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
- GuiData->CharWidth = CharSize.cx;
-
- SelectObject(hDC, OldFont);
-
- ReleaseDC(GuiData->hWindow, hDC);
/* Initialize the terminal framebuffer */
GuiData->hMemDC = CreateCompatibleDC(NULL);
@@ -1341,7 +1443,7 @@
if (GuiData->hMemDC ) DeleteDC(GuiData->hMemDC);
if (GuiData->hBitmap) DeleteObject(GuiData->hBitmap);
// if (GuiData->hSysPalette) DeleteObject(GuiData->hSysPalette);
- if (GuiData->Font) DeleteObject(GuiData->Font);
+ DeleteFonts(GuiData);
}
/* Free the GuiData registration */
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/conwnd.h [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -21,6 +21,17 @@
#define PM_CONSOLE_BEEP (WM_APP + 4)
#define PM_CONSOLE_SET_TITLE (WM_APP + 5)
+/*
+typedef struct _CONSOLE_FONT
+{
+ HFONT Font;
+ ULONG Flag;
+} CONSOLE_FONT, *PCONSOLE_FONT;
+*/
+#define FONT_NORMAL 0x00
+#define FONT_BOLD 0x01
+#define FONT_UNDERLINE 0x02
+#define FONT_MAXNO 0x04
typedef struct _GUI_CONSOLE_DATA
{
@@ -56,9 +67,9 @@
// PVOID ScreenBuffer; /* Hardware screen buffer */
- HFONT Font;
- UINT CharWidth;
- UINT CharHeight;
+ HFONT Font[FONT_MAXNO];
+ UINT CharWidth; /* The character width and height should be the same for */
+ UINT CharHeight; /* both normal and bold/underlined fonts... */
/*****************************************************/
PCONSRV_CONSOLE Console; /* Pointer to the owned console */
Modified:
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.c [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -16,9 +16,6 @@
#include "guiterm.h"
#include "guisettings.h"
-
-VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
-VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
/* FUNCTIONS ******************************************************************/
@@ -199,14 +196,14 @@
// wcsncpy(TermInfo->FaceName, L"DejaVu Sans Mono", LF_FACESIZE);
// TermInfo->FontSize = MAKELONG(8, 12); // 0x000C0008; // font is 8x12
// TermInfo->FontSize = MAKELONG(16, 16); // font is 16x16
- // TermInfo->FontWeight = FW_NORMAL;
wcsncpy(TermInfo->FaceName, L"VGA", LF_FACESIZE); // HACK: !!
// TermInfo->FaceName[0] = L'\0';
TermInfo->FontFamily = FF_DONTCARE;
TermInfo->FontSize.X = 0;
TermInfo->FontSize.Y = 0;
- TermInfo->FontWeight = FW_DONTCARE;
+ TermInfo->FontWeight = FW_NORMAL; // HACK: !!
+ // TermInfo->FontWeight = FW_DONTCARE;
TermInfo->FullScreen = FALSE;
TermInfo->ShowWindow = SW_SHOWNORMAL;
@@ -418,92 +415,6 @@
return;
}
-
-
-
-BOOL
-ChangeFont(PGUI_CONSOLE_DATA GuiData,
- LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
- ULONG FontFamily,
- COORD FontSize,
- ULONG FontWeight)
-{
- HDC hDC;
- HFONT OldFont, NewFont;
- TEXTMETRICW Metrics;
- SIZE CharSize;
- SIZE_T Length;
-
- NewFont = CreateFontW(FontSize.Y,
- 0, // FontSize.X,
- 0,
- TA_BASELINE,
- FontWeight,
- FALSE,
- FALSE,
- FALSE,
- OEM_CHARSET,
- OUT_DEFAULT_PRECIS,
- CLIP_DEFAULT_PRECIS,
- NONANTIALIASED_QUALITY,
- FIXED_PITCH | FontFamily /* FF_DONTCARE */,
- FaceName);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFont: CreateFont failed\n");
- return FALSE;
- }
-
- hDC = GetDC(GuiData->hWindow);
- if (hDC == NULL)
- {
- DPRINT1("ChangeFont: GetDC failed\n");
- DeleteObject(NewFont);
- return FALSE;
- }
-
- OldFont = SelectObject(hDC, NewFont);
- if (OldFont == NULL)
- {
- DPRINT1("ChangeFont: SelectObject failed\n");
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(NewFont);
- return FALSE;
- }
-
- if (!GetTextMetricsW(hDC, &Metrics))
- {
- DPRINT1("ChangeFont: GetTextMetrics failed\n");
- SelectObject(hDC, OldFont);
- ReleaseDC(GuiData->hWindow, hDC);
- DeleteObject(NewFont);
- return FALSE;
- }
- GuiData->CharWidth = Metrics.tmMaxCharWidth;
- GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
-
- /* Measure real char width more precisely if possible. */
- if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
- GuiData->CharWidth = CharSize.cx;
-
- SelectObject(hDC, OldFont);
- ReleaseDC(GuiData->hWindow, hDC);
-
- if (GuiData->Font != NULL) DeleteObject(GuiData->Font);
- GuiData->Font = NewFont;
-
- Length = min(wcslen(FaceName) + 1, LF_FACESIZE); // wcsnlen
- wcsncpy(GuiData->GuiInfo.FaceName, FaceName, LF_FACESIZE);
- GuiData->GuiInfo.FaceName[Length] = L'\0'; // NULL-terminate
- GuiData->GuiInfo.FontFamily = FontFamily;
- GuiData->GuiInfo.FontSize = FontSize;
- GuiData->GuiInfo.FontWeight = FontWeight;
-
- return TRUE;
-}
-
-
-
VOID
GuiApplyUserSettings(PGUI_CONSOLE_DATA GuiData,
HANDLE hClientSection,
@@ -586,11 +497,11 @@
// memcpy(&GuiData->GuiInfo, GuiInfo, sizeof(GUI_CONSOLE_INFO));
/* Change the font */
- ChangeFont(GuiData,
- GuiInfo->FaceName,
- GuiInfo->FontFamily,
- GuiInfo->FontSize,
- GuiInfo->FontWeight);
+ InitFonts(GuiData,
+ GuiInfo->FaceName,
+ GuiInfo->FontFamily,
+ GuiInfo->FontSize,
+ GuiInfo->FontWeight);
// HACK, needed because changing font may change the size of the window
/**/TermResizeTerminal(Console);/**/
@@ -768,11 +679,11 @@
// memcpy(&GuiData->GuiInfo, &GuiInfo, sizeof(GUI_CONSOLE_INFO));
/* Change the font */
- ChangeFont(GuiData,
- GuiInfo.FaceName,
- GuiInfo.FontFamily,
- GuiInfo.FontSize,
- GuiInfo.FontWeight);
+ InitFonts(GuiData,
+ GuiInfo.FaceName,
+ GuiInfo.FontFamily,
+ GuiInfo.FontSize,
+ GuiInfo.FontWeight);
// HACK, needed because changing font may change the size of the window
/**/TermResizeTerminal(Console);/**/
Modified:
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -29,7 +29,6 @@
typedef struct _GUI_CONSOLE_INFO
{
- // FONTSIGNATURE FontSignature;
WCHAR FaceName[LF_FACESIZE];
ULONG FontFamily;
COORD FontSize;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/guiterm.h [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -20,3 +20,18 @@
DWORD ProcessId,
LPCWSTR IconPath,
INT IconIndex);
+
+VOID
+GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData);
+
+VOID
+SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen);
+
+BOOL
+InitFonts(PGUI_CONSOLE_DATA GuiData,
+ LPWSTR FaceName, // Points to a WCHAR array of LF_FACESIZE elements.
+ ULONG FontFamily,
+ COORD FontSize,
+ ULONG FontWeight);
+VOID
+DeleteFonts(PGUI_CONSOLE_DATA GuiData);
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/text.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
---
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/text.c [iso-8859-1]
(original)
+++
branches/condrv_restructure/win32ss/user/winsrv/consrv/frontends/gui/text.c [iso-8859-1]
Thu Aug 14 20:10:00 2014
@@ -34,44 +34,6 @@
GetPaletteEntries(hPalette, Attribute, 1, &pe);
return PALETTERGB(pe.peRed, pe.peGreen, pe.peBlue);
-}
-
-static HFONT
-ChangeFontAttributes(PGUI_CONSOLE_DATA GuiData,
- // COORD FontSize,
- ULONG FontWeight,
- BOOLEAN bItalic,
- BOOLEAN bUnderline,
- BOOLEAN bStrikeOut)
-{
- HFONT NewFont;
- LOGFONT lf;
-
- /* Initialize the LOGFONT structure */
- RtlZeroMemory(&lf, sizeof(lf));
-
- /* Retrieve the details of the current font */
- if (GetObject(GuiData->Font, sizeof(lf), &lf) == 0)
- return NULL; // GuiData->Font;
-
- /* Change the font attributes */
- // lf.lfHeight = FontSize.Y;
- // lf.lfWidth = FontSize.X;
- lf.lfWeight = FontWeight;
- lf.lfItalic = bItalic;
- lf.lfUnderline = bUnderline;
- lf.lfStrikeOut = bStrikeOut;
-
- /* Build a new font */
- NewFont = CreateFontIndirect(&lf);
- if (NewFont == NULL)
- return NULL; // GuiData->Font;
-
- // FIXME: Do we need to update GuiData->CharWidth and GuiData->CharHeight ??
-
- /* Select it (return the old font) */
- // return SelectObject(GuiData->hMemDC, NewFont);
- return NewFont;
}
static VOID
@@ -388,7 +350,7 @@
ULONG CursorX, CursorY, CursorHeight;
HBRUSH CursorBrush, OldBrush;
HFONT OldFont, NewFont;
- BOOLEAN IsUnderscore;
+ BOOLEAN IsUnderline;
if (Buffer->Buffer == NULL) return;
@@ -412,17 +374,10 @@
SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
TextAttribFromAttrib(LastAttribute)));
SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
BkgdAttribFromAttrib(LastAttribute)));
- // OldFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight,
FALSE, FALSE, FALSE);
- IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
- NewFont = ChangeFontAttributes(GuiData, /* {0}, */ GuiData->GuiInfo.FontWeight,
- FALSE,
- IsUnderscore,
- FALSE);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFontAttributes failed, use the original font\n");
- NewFont = GuiData->Font;
- }
+ /* We use the underscore flag as a underline flag */
+ IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
+ /* Select the new font */
+ NewFont = GuiData->Font[IsUnderline ? FONT_BOLD : FONT_NORMAL];
OldFont = SelectObject(GuiData->hMemDC, NewFont);
for (Line = TopLine; Line <= BottomLine; Line++)
@@ -454,25 +409,12 @@
SetTextColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
TextAttribFromAttrib(LastAttribute)));
SetBkColor(GuiData->hMemDC, PaletteRGBFromAttrib(Console,
BkgdAttribFromAttrib(LastAttribute)));
- /* Change underscore state if needed */
- if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderscore)
+ /* Change underline state if needed */
+ if (!!(LastAttribute & COMMON_LVB_UNDERSCORE) != IsUnderline)
{
- IsUnderscore = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
-
- /* Delete the font we used up to now */
- // SelectObject(GuiData->hMemDC, OldFont);
- if (NewFont != GuiData->Font) DeleteObject(NewFont);
- /* Recreate it */
- NewFont = ChangeFontAttributes(GuiData, /* {0}, */
GuiData->GuiInfo.FontWeight,
- FALSE,
- IsUnderscore,
- FALSE);
- if (NewFont == NULL)
- {
- DPRINT1("ChangeFontAttributes failed, use the original
font\n");
- NewFont = GuiData->Font;
- }
- /* Select it */
+ IsUnderline = !!(LastAttribute & COMMON_LVB_UNDERSCORE);
+ /* Select the new font */
+ NewFont = GuiData->Font[IsUnderline ? FONT_BOLD :
FONT_NORMAL];
/* OldFont = */ SelectObject(GuiData->hMemDC, NewFont);
}
}
@@ -487,6 +429,9 @@
LineBuffer,
RightChar - Start + 1);
}
+
+ /* Restore the old font */
+ SelectObject(GuiData->hMemDC, OldFont);
/*
* Draw the caret
@@ -520,10 +465,6 @@
}
}
- /* Restore the old font and delete the font we used up to now */
- SelectObject(GuiData->hMemDC, OldFont);
- if (NewFont != GuiData->Font) DeleteObject(NewFont);
-
LeaveCriticalSection(&Console->Lock);
}