From 9fc839608806c601d8c6f5a680b6f6589d55cf75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Fri, 15 Aug 2014 20:00:47 +0000 Subject: [PATCH] =?utf8?q?[CONSOLE.CPL][CONSRV]:=20Font=20fix=20n=C2=B01:?= =?utf8?q?=20correctly=20use=20the=20font=20size=20(for=20TT=20fonts=20onl?= =?utf8?q?y,=20at=20the=20moment).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/branches/condrv_restructure/; revision=63896 --- dll/cpl/console/font.c | 24 +++++++++---------- dll/cpl/console/layout.c | 13 ++++++---- .../user/winsrv/consrv/frontends/gui/conwnd.c | 18 +++++++------- .../winsrv/consrv/frontends/gui/guisettings.h | 2 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/dll/cpl/console/font.c b/dll/cpl/console/font.c index d714e63fa13..aa57201c9b0 100644 --- a/dll/cpl/console/font.c +++ b/dll/cpl/console/font.c @@ -72,7 +72,7 @@ GuiData->CharWidth = Metrics.tmMaxCharWidth; GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading; - /* Measure real char width more precisely if possible. */ + /* Measure real char width more precisely if possible */ if (GetTextExtentPoint32W(drawItem->hDC, L"R", 1, &CharSize)) GuiData->CharWidth = CharSize.cx; } @@ -102,12 +102,9 @@ EnumFontNamesProc(PLOGFONTW lplf, HWND hwndCombo = (HWND)lParam; LPWSTR pszName = lplf->lfFaceName; - BOOL fFixed; - BOOL fTrueType; - /* Record the font's attributes (Fixedwidth and Truetype) */ - fFixed = ((lplf->lfPitchAndFamily & 0x03) == FIXED_PITCH); - fTrueType = (lplf->lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE; + // BOOL fFixed = ((lplf->lfPitchAndFamily & 0x03) == FIXED_PITCH); + // BOOL fTrueType = (lplf->lfOutPrecision == OUT_STROKE_PRECIS); /* * According to: http://support.microsoft.com/kb/247815 @@ -158,7 +155,8 @@ EnumFontNamesProc(PLOGFONTW lplf, /* Reject TrueType fonts that are not FF_MODERN */ if ((FontType == TRUETYPE_FONTTYPE) && ((lplf->lfPitchAndFamily & 0xF0) != FF_MODERN)) { - DPRINT1("TrueType font '%S' rejected because it's not FF_MODERN (lfPitchAndFamily = %d)\n", pszName, lplf->lfPitchAndFamily); + DPRINT1("TrueType font '%S' rejected because it's not FF_MODERN (lfPitchAndFamily = %d)\n", + pszName, lplf->lfPitchAndFamily); return TRUE; } @@ -166,14 +164,16 @@ EnumFontNamesProc(PLOGFONTW lplf, #if 0 if ((FontType != TRUETYPE_FONTTYPE) && (lplf->lfCharSet != OEM_CHARSET)) { - DPRINT1("Non-TrueType font '%S' rejected because it's not OEM_CHARSET %d\n", pszName, lplf->lfCharSet); + DPRINT1("Non-TrueType font '%S' rejected because it's not OEM_CHARSET %d\n", + pszName, lplf->lfCharSet); return TRUE; } #else // Improved criterium 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); + 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 @@ -205,7 +205,8 @@ EnumFontNamesProc(PLOGFONTW lplf, DPRINT1("Add font '%S' (lfPitchAndFamily = %d)\n", pszName, lplf->lfPitchAndFamily); /* Store this information in the list-item's userdata area */ - SendMessageW(hwndCombo, LB_SETITEMDATA, idx, MAKEWPARAM(fFixed, fTrueType)); + // SendMessageW(hwndCombo, LB_SETITEMDATA, idx, MAKEWPARAM(fFixed, fTrueType)); + SendMessageW(hwndCombo, LB_SETITEMDATA, idx, (WPARAM)FontType); } return TRUE; @@ -247,7 +248,7 @@ EnumFontSizesProc(PLOGFONTW lplf, } else { - int i; + ULONG i; for (i = 0; i < sizeof(TrueTypePoints) / sizeof(TrueTypePoints[0]); ++i) { swprintf(FontSize, L"%2d", TrueTypePoints[i]); @@ -273,7 +274,6 @@ EnumFontSizesProc(PLOGFONTW lplf, } - static VOID FontSizeChange(HWND hwndDlg, PGUI_CONSOLE_INFO GuiInfo); diff --git a/dll/cpl/console/layout.c b/dll/cpl/console/layout.c index 90926c821c2..1b99e400b9c 100644 --- a/dll/cpl/console/layout.c +++ b/dll/cpl/console/layout.c @@ -107,6 +107,8 @@ PaintText(LPDRAWITEMSTRUCT drawItem, HBRUSH hBrush; HFONT Font, OldFont; + COORD FontSize = GuiInfo->FontSize; + if (TextMode == Screen) CurrentAttrib = pConInfo->ci.ScreenAttrib; else if (TextMode == Popup) @@ -120,8 +122,11 @@ PaintText(LPDRAWITEMSTRUCT drawItem, hBrush = CreateSolidBrush(nbkColor); if (!hBrush) return FALSE; - Font = CreateFontW(GuiInfo->FontSize.Y, - GuiInfo->FontSize.X, + FontSize.Y = FontSize.Y > 0 ? -MulDiv(FontSize.Y, GetDeviceCaps(drawItem->hDC, LOGPIXELSY), 72) + : FontSize.Y; + + Font = CreateFontW(FontSize.Y, + FontSize.X, 0, TA_BASELINE, GuiInfo->FontWeight, @@ -131,7 +136,7 @@ PaintText(LPDRAWITEMSTRUCT drawItem, OEM_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY + DEFAULT_QUALITY, FIXED_PITCH | GuiInfo->FontFamily, GuiInfo->FaceName); if (Font == NULL) @@ -154,7 +159,7 @@ PaintText(LPDRAWITEMSTRUCT drawItem, DrawTextW(drawItem->hDC, szPreviewText, wcslen(szPreviewText), &drawItem->rcItem, 0); SetTextColor(drawItem->hDC, ptColor); SetBkColor(drawItem->hDC, pbkColor); - DeleteObject((HGDIOBJ)hBrush); + DeleteObject(hBrush); SelectObject(drawItem->hDC, OldFont); DeleteObject(Font); diff --git a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c index 84de1871b20..11a5a090454 100644 --- a/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c +++ b/win32ss/user/winsrv/consrv/frontends/gui/conwnd.c @@ -539,10 +539,15 @@ InitFonts(PGUI_CONSOLE_DATA GuiData, TEXTMETRICW Metrics; SIZE CharSize; + hDC = GetDC(GuiData->hWindow); + /* * Initialize a new NORMAL font and get its metrics. */ + FontSize.Y = FontSize.Y > 0 ? -MulDiv(FontSize.Y, GetDeviceCaps(hDC, LOGPIXELSY), 72) + : FontSize.Y; + NewFont = CreateFontW(FontSize.Y, FontSize.X, 0, @@ -554,20 +559,13 @@ InitFonts(PGUI_CONSOLE_DATA GuiData, OEM_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY + DEFAULT_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); + ReleaseDC(GuiData->hWindow, hDC); return FALSE; } @@ -591,7 +589,7 @@ InitFonts(PGUI_CONSOLE_DATA GuiData, GuiData->CharWidth = Metrics.tmMaxCharWidth; GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading; - /* Measure real char width more precisely if possible. */ + /* Measure real char width more precisely if possible */ if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize)) GuiData->CharWidth = CharSize.cx; diff --git a/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h b/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h index 593c14e5e2d..792fe1db81c 100644 --- a/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h +++ b/win32ss/user/winsrv/consrv/frontends/gui/guisettings.h @@ -76,7 +76,7 @@ typedef struct _CONSOLE_STATE_INFO COLORREF ColorTable[16]; ULONG CodePage; - HWND HWnd; + HWND hWnd; WCHAR ConsoleTitle[256]; } CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO; -- 2.17.1