mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:33:07 +00:00
- give the fontview class an EXTLOGFONT to set the font, fixes display of wrong font style.
- add font size 8 svn path=/trunk/; revision=32791
This commit is contained in:
parent
47034d9d29
commit
95af11a848
3 changed files with 28 additions and 32 deletions
|
@ -140,7 +140,7 @@ Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos)
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT
|
static LRESULT
|
||||||
Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)
|
||||||
{
|
{
|
||||||
DISPLAYDATA* pData;
|
DISPLAYDATA* pData;
|
||||||
TEXTMETRIC tm;
|
TEXTMETRIC tm;
|
||||||
|
@ -148,19 +148,19 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
||||||
RECT rect;
|
RECT rect;
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
int i;
|
int i;
|
||||||
|
LOGFONTW logfont;
|
||||||
|
|
||||||
/* Set the new type face name */
|
/* Set the new type face name */
|
||||||
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||||
snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, (WCHAR*)lParam);
|
snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, pExtLogFont->elfFullName);
|
||||||
|
|
||||||
/* Create the new fonts */
|
/* Create the new fonts */
|
||||||
hDC = GetDC(hwnd);
|
hDC = GetDC(hwnd);
|
||||||
DeleteObject(pData->hCharSetFont);
|
DeleteObject(pData->hCharSetFont);
|
||||||
pData->hCharSetFont = CreateFontW(-MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72),
|
|
||||||
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
logfont = pExtLogFont->elfLogFont;
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
|
||||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
pData->hCharSetFont = CreateFontIndirectW(&logfont);
|
||||||
DEFAULT_PITCH , pData->szTypeFaceName);
|
|
||||||
|
|
||||||
/* Get font format */
|
/* Get font format */
|
||||||
// FIXME: Get the real font format (OpenType?)
|
// FIXME: Get the real font format (OpenType?)
|
||||||
|
@ -174,11 +174,8 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
||||||
for (i = 0; i < MAX_SIZES; i++)
|
for (i = 0; i < MAX_SIZES; i++)
|
||||||
{
|
{
|
||||||
DeleteObject(pData->hFonts[i]);
|
DeleteObject(pData->hFonts[i]);
|
||||||
pData->hFonts[i] = CreateFontW(-MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72),
|
logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
||||||
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
pData->hFonts[i] = CreateFontIndirectW(&logfont);
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
|
||||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
|
||||||
DEFAULT_PITCH , pData->szTypeFaceName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate new page dimensions */
|
/* Calculate new page dimensions */
|
||||||
|
@ -216,8 +213,13 @@ static LRESULT
|
||||||
Display_OnCreate(HWND hwnd)
|
Display_OnCreate(HWND hwnd)
|
||||||
{
|
{
|
||||||
DISPLAYDATA* pData;
|
DISPLAYDATA* pData;
|
||||||
const int nSizes[MAX_SIZES] = {12, 18, 24, 36, 48, 60, 72};
|
const int nSizes[MAX_SIZES] = {8, 12, 18, 24, 36, 48, 60, 72};
|
||||||
int i;
|
int i;
|
||||||
|
EXTLOGFONTW ExtLogFont = {{50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||||
|
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
||||||
|
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
||||||
|
DEFAULT_PITCH , L"Ms Shell Dlg"},
|
||||||
|
L"Ms Shell Dlg"};
|
||||||
|
|
||||||
/* Create data structure */
|
/* Create data structure */
|
||||||
pData = malloc(sizeof(DISPLAYDATA));
|
pData = malloc(sizeof(DISPLAYDATA));
|
||||||
|
@ -231,18 +233,13 @@ Display_OnCreate(HWND hwnd)
|
||||||
pData->nSizes[i] = nSizes[i];
|
pData->nSizes[i] = nSizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
pData->hCaptionFont = CreateFontW(50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
pData->hCaptionFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
ExtLogFont.elfLogFont.lfHeight = 12;
|
||||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
pData->hSizeFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);
|
||||||
DEFAULT_PITCH , L"Ms Shell Dlg");
|
|
||||||
|
|
||||||
pData->hSizeFont = CreateFontW(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
|
||||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
|
||||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
|
||||||
DEFAULT_PITCH , L"Ms Shell Dlg");
|
|
||||||
|
|
||||||
Display_SetString(hwnd, (LPARAM)L"Jackdaws love my big sphinx of quartz. 1234567890");
|
Display_SetString(hwnd, (LPARAM)L"Jackdaws love my big sphinx of quartz. 1234567890");
|
||||||
Display_SetTypeFace(hwnd, (LPARAM)L"Ms Shell Dlg");
|
|
||||||
|
Display_SetTypeFace(hwnd, &ExtLogFont);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -398,7 +395,7 @@ DisplayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
return Display_OnVScroll(hwnd, wParam);
|
return Display_OnVScroll(hwnd, wParam);
|
||||||
|
|
||||||
case FVM_SETTYPEFACE:
|
case FVM_SETTYPEFACE:
|
||||||
return Display_SetTypeFace(hwnd, lParam);
|
return Display_SetTypeFace(hwnd, (PEXTLOGFONTW)lParam);
|
||||||
|
|
||||||
case FVM_SETSTRING:
|
case FVM_SETSTRING:
|
||||||
return Display_SetString(hwnd, lParam);
|
return Display_SetString(hwnd, lParam);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
/* Size restrictions */
|
/* Size restrictions */
|
||||||
#define MAX_STRING 100
|
#define MAX_STRING 100
|
||||||
#define MAX_FORMAT 20
|
#define MAX_FORMAT 20
|
||||||
#define MAX_SIZES 7
|
#define MAX_SIZES 8
|
||||||
|
|
||||||
extern const WCHAR g_szFontDisplayClassName[];
|
extern const WCHAR g_szFontDisplayClassName[];
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@
|
||||||
#include "fontview.h"
|
#include "fontview.h"
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
HINSTANCE g_hInstance;
|
||||||
WCHAR g_szTypeFaceName[LF_FULLFACESIZE];
|
EXTLOGFONTW g_ExtLogFontW;
|
||||||
LOGFONTW g_LogFontW;
|
|
||||||
|
|
||||||
static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";
|
static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";
|
||||||
|
|
||||||
|
@ -117,15 +116,15 @@ WinMain (HINSTANCE hThisInstance,
|
||||||
PGFRI GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");
|
PGFRI GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");
|
||||||
|
|
||||||
/* Get the font name */
|
/* Get the font name */
|
||||||
dwSize = sizeof(g_szTypeFaceName);
|
dwSize = sizeof(g_ExtLogFontW.elfFullName);
|
||||||
if (!GetFontResourceInfoW(argv[1], &dwSize, g_szTypeFaceName, 1))
|
if (!GetFontResourceInfoW(argv[1], &dwSize, g_ExtLogFontW.elfFullName, 1))
|
||||||
{
|
{
|
||||||
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwSize = sizeof(LOGFONTW);
|
dwSize = sizeof(LOGFONTW);
|
||||||
if (!GetFontResourceInfoW(argv[1], &dwSize, &g_LogFontW, 2))
|
if (!GetFontResourceInfoW(argv[1], &dwSize, &g_ExtLogFontW.elfLogFont, 2))
|
||||||
{
|
{
|
||||||
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -162,7 +161,7 @@ WinMain (HINSTANCE hThisInstance,
|
||||||
hMainWnd = CreateWindowExW(
|
hMainWnd = CreateWindowExW(
|
||||||
0, /* Extended possibilites for variation */
|
0, /* Extended possibilites for variation */
|
||||||
g_szFontViewClassName, /* Classname */
|
g_szFontViewClassName, /* Classname */
|
||||||
g_szTypeFaceName, /* Title Text */
|
g_ExtLogFontW.elfFullName,/* Title Text */
|
||||||
WS_OVERLAPPEDWINDOW, /* default window */
|
WS_OVERLAPPEDWINDOW, /* default window */
|
||||||
CW_USEDEFAULT, /* Windows decides the position */
|
CW_USEDEFAULT, /* Windows decides the position */
|
||||||
CW_USEDEFAULT, /* where the window ends up on the screen */
|
CW_USEDEFAULT, /* where the window ends up on the screen */
|
||||||
|
@ -215,7 +214,7 @@ MainWnd_OnCreate(HWND hwnd)
|
||||||
SendMessage(hDisplay, FVM_SETSTRING, 0, (LPARAM)szString);
|
SendMessage(hDisplay, FVM_SETSTRING, 0, (LPARAM)szString);
|
||||||
|
|
||||||
/* Init the display window with the font name */
|
/* Init the display window with the font name */
|
||||||
SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_LogFontW.lfFaceName);
|
SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_ExtLogFontW);
|
||||||
ShowWindow(hDisplay, SW_SHOWNORMAL);
|
ShowWindow(hDisplay, SW_SHOWNORMAL);
|
||||||
|
|
||||||
/* Create the quit button */
|
/* Create the quit button */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue