[CONSOLE.CPL][CONSRV]: Font fix n°1: correctly use the font size (for TT fonts only, at the moment).

svn path=/branches/condrv_restructure/; revision=63896
This commit is contained in:
Hermès Bélusca-Maïto 2014-08-15 20:00:47 +00:00
parent 21b5377d35
commit 9fc8396088
4 changed files with 30 additions and 27 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;