mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 22:56:00 +00:00
[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:
parent
21b5377d35
commit
9fc8396088
4 changed files with 30 additions and 27 deletions
|
@ -72,7 +72,7 @@
|
||||||
GuiData->CharWidth = Metrics.tmMaxCharWidth;
|
GuiData->CharWidth = Metrics.tmMaxCharWidth;
|
||||||
GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
|
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))
|
if (GetTextExtentPoint32W(drawItem->hDC, L"R", 1, &CharSize))
|
||||||
GuiData->CharWidth = CharSize.cx;
|
GuiData->CharWidth = CharSize.cx;
|
||||||
}
|
}
|
||||||
|
@ -102,12 +102,9 @@ EnumFontNamesProc(PLOGFONTW lplf,
|
||||||
HWND hwndCombo = (HWND)lParam;
|
HWND hwndCombo = (HWND)lParam;
|
||||||
LPWSTR pszName = lplf->lfFaceName;
|
LPWSTR pszName = lplf->lfFaceName;
|
||||||
|
|
||||||
BOOL fFixed;
|
|
||||||
BOOL fTrueType;
|
|
||||||
|
|
||||||
/* Record the font's attributes (Fixedwidth and Truetype) */
|
/* Record the font's attributes (Fixedwidth and Truetype) */
|
||||||
fFixed = ((lplf->lfPitchAndFamily & 0x03) == FIXED_PITCH);
|
// BOOL fFixed = ((lplf->lfPitchAndFamily & 0x03) == FIXED_PITCH);
|
||||||
fTrueType = (lplf->lfOutPrecision == OUT_STROKE_PRECIS) ? TRUE : FALSE;
|
// BOOL fTrueType = (lplf->lfOutPrecision == OUT_STROKE_PRECIS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* According to: http://support.microsoft.com/kb/247815
|
* According to: http://support.microsoft.com/kb/247815
|
||||||
|
@ -158,7 +155,8 @@ EnumFontNamesProc(PLOGFONTW lplf,
|
||||||
/* Reject TrueType fonts that are not FF_MODERN */
|
/* Reject TrueType fonts that are not FF_MODERN */
|
||||||
if ((FontType == TRUETYPE_FONTTYPE) && ((lplf->lfPitchAndFamily & 0xF0) != 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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,14 +164,16 @@ EnumFontNamesProc(PLOGFONTW lplf,
|
||||||
#if 0
|
#if 0
|
||||||
if ((FontType != TRUETYPE_FONTTYPE) && (lplf->lfCharSet != OEM_CHARSET))
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#else // Improved criterium
|
#else // Improved criterium
|
||||||
if ((FontType != TRUETYPE_FONTTYPE) &&
|
if ((FontType != TRUETYPE_FONTTYPE) &&
|
||||||
((lplf->lfCharSet != ANSI_CHARSET) && (lplf->lfCharSet != DEFAULT_CHARSET) && (lplf->lfCharSet != OEM_CHARSET)))
|
((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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -205,7 +205,8 @@ EnumFontNamesProc(PLOGFONTW lplf,
|
||||||
DPRINT1("Add font '%S' (lfPitchAndFamily = %d)\n", pszName, lplf->lfPitchAndFamily);
|
DPRINT1("Add font '%S' (lfPitchAndFamily = %d)\n", pszName, lplf->lfPitchAndFamily);
|
||||||
|
|
||||||
/* Store this information in the list-item's userdata area */
|
/* 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;
|
return TRUE;
|
||||||
|
@ -247,7 +248,7 @@ EnumFontSizesProc(PLOGFONTW lplf,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
ULONG i;
|
||||||
for (i = 0; i < sizeof(TrueTypePoints) / sizeof(TrueTypePoints[0]); ++i)
|
for (i = 0; i < sizeof(TrueTypePoints) / sizeof(TrueTypePoints[0]); ++i)
|
||||||
{
|
{
|
||||||
swprintf(FontSize, L"%2d", TrueTypePoints[i]);
|
swprintf(FontSize, L"%2d", TrueTypePoints[i]);
|
||||||
|
@ -273,7 +274,6 @@ EnumFontSizesProc(PLOGFONTW lplf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
FontSizeChange(HWND hwndDlg,
|
FontSizeChange(HWND hwndDlg,
|
||||||
PGUI_CONSOLE_INFO GuiInfo);
|
PGUI_CONSOLE_INFO GuiInfo);
|
||||||
|
|
|
@ -107,6 +107,8 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
|
||||||
HBRUSH hBrush;
|
HBRUSH hBrush;
|
||||||
HFONT Font, OldFont;
|
HFONT Font, OldFont;
|
||||||
|
|
||||||
|
COORD FontSize = GuiInfo->FontSize;
|
||||||
|
|
||||||
if (TextMode == Screen)
|
if (TextMode == Screen)
|
||||||
CurrentAttrib = pConInfo->ci.ScreenAttrib;
|
CurrentAttrib = pConInfo->ci.ScreenAttrib;
|
||||||
else if (TextMode == Popup)
|
else if (TextMode == Popup)
|
||||||
|
@ -120,8 +122,11 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
|
||||||
hBrush = CreateSolidBrush(nbkColor);
|
hBrush = CreateSolidBrush(nbkColor);
|
||||||
if (!hBrush) return FALSE;
|
if (!hBrush) return FALSE;
|
||||||
|
|
||||||
Font = CreateFontW(GuiInfo->FontSize.Y,
|
FontSize.Y = FontSize.Y > 0 ? -MulDiv(FontSize.Y, GetDeviceCaps(drawItem->hDC, LOGPIXELSY), 72)
|
||||||
GuiInfo->FontSize.X,
|
: FontSize.Y;
|
||||||
|
|
||||||
|
Font = CreateFontW(FontSize.Y,
|
||||||
|
FontSize.X,
|
||||||
0,
|
0,
|
||||||
TA_BASELINE,
|
TA_BASELINE,
|
||||||
GuiInfo->FontWeight,
|
GuiInfo->FontWeight,
|
||||||
|
@ -131,7 +136,7 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
|
||||||
OEM_CHARSET,
|
OEM_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,
|
OUT_DEFAULT_PRECIS,
|
||||||
CLIP_DEFAULT_PRECIS,
|
CLIP_DEFAULT_PRECIS,
|
||||||
DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY
|
DEFAULT_QUALITY,
|
||||||
FIXED_PITCH | GuiInfo->FontFamily,
|
FIXED_PITCH | GuiInfo->FontFamily,
|
||||||
GuiInfo->FaceName);
|
GuiInfo->FaceName);
|
||||||
if (Font == NULL)
|
if (Font == NULL)
|
||||||
|
@ -154,7 +159,7 @@ PaintText(LPDRAWITEMSTRUCT drawItem,
|
||||||
DrawTextW(drawItem->hDC, szPreviewText, wcslen(szPreviewText), &drawItem->rcItem, 0);
|
DrawTextW(drawItem->hDC, szPreviewText, wcslen(szPreviewText), &drawItem->rcItem, 0);
|
||||||
SetTextColor(drawItem->hDC, ptColor);
|
SetTextColor(drawItem->hDC, ptColor);
|
||||||
SetBkColor(drawItem->hDC, pbkColor);
|
SetBkColor(drawItem->hDC, pbkColor);
|
||||||
DeleteObject((HGDIOBJ)hBrush);
|
DeleteObject(hBrush);
|
||||||
|
|
||||||
SelectObject(drawItem->hDC, OldFont);
|
SelectObject(drawItem->hDC, OldFont);
|
||||||
DeleteObject(Font);
|
DeleteObject(Font);
|
||||||
|
|
|
@ -539,10 +539,15 @@ InitFonts(PGUI_CONSOLE_DATA GuiData,
|
||||||
TEXTMETRICW Metrics;
|
TEXTMETRICW Metrics;
|
||||||
SIZE CharSize;
|
SIZE CharSize;
|
||||||
|
|
||||||
|
hDC = GetDC(GuiData->hWindow);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize a new NORMAL font and get its metrics.
|
* 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,
|
NewFont = CreateFontW(FontSize.Y,
|
||||||
FontSize.X,
|
FontSize.X,
|
||||||
0,
|
0,
|
||||||
|
@ -554,20 +559,13 @@ InitFonts(PGUI_CONSOLE_DATA GuiData,
|
||||||
OEM_CHARSET,
|
OEM_CHARSET,
|
||||||
OUT_DEFAULT_PRECIS,
|
OUT_DEFAULT_PRECIS,
|
||||||
CLIP_DEFAULT_PRECIS,
|
CLIP_DEFAULT_PRECIS,
|
||||||
DEFAULT_QUALITY, // NONANTIALIASED_QUALITY ; ANTIALIASED_QUALITY
|
DEFAULT_QUALITY,
|
||||||
FIXED_PITCH | FontFamily,
|
FIXED_PITCH | FontFamily,
|
||||||
FaceName);
|
FaceName);
|
||||||
if (NewFont == NULL)
|
if (NewFont == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("InitFonts: CreateFontW failed\n");
|
DPRINT1("InitFonts: CreateFontW failed\n");
|
||||||
return FALSE;
|
ReleaseDC(GuiData->hWindow, hDC);
|
||||||
}
|
|
||||||
|
|
||||||
hDC = GetDC(GuiData->hWindow);
|
|
||||||
if (hDC == NULL)
|
|
||||||
{
|
|
||||||
DPRINT1("InitFonts: GetDC failed\n");
|
|
||||||
DeleteObject(NewFont);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,7 +589,7 @@ InitFonts(PGUI_CONSOLE_DATA GuiData,
|
||||||
GuiData->CharWidth = Metrics.tmMaxCharWidth;
|
GuiData->CharWidth = Metrics.tmMaxCharWidth;
|
||||||
GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
|
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))
|
if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
|
||||||
GuiData->CharWidth = CharSize.cx;
|
GuiData->CharWidth = CharSize.cx;
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ typedef struct _CONSOLE_STATE_INFO
|
||||||
COLORREF ColorTable[16];
|
COLORREF ColorTable[16];
|
||||||
|
|
||||||
ULONG CodePage;
|
ULONG CodePage;
|
||||||
HWND HWnd;
|
HWND hWnd;
|
||||||
|
|
||||||
WCHAR ConsoleTitle[256];
|
WCHAR ConsoleTitle[256];
|
||||||
} CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO;
|
} CONSOLE_STATE_INFO, *PCONSOLE_STATE_INFO;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue