mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:25:52 +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
|
||||
Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
||||
Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)
|
||||
{
|
||||
DISPLAYDATA* pData;
|
||||
TEXTMETRIC tm;
|
||||
|
@ -148,19 +148,19 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
|||
RECT rect;
|
||||
SCROLLINFO si;
|
||||
int i;
|
||||
LOGFONTW logfont;
|
||||
|
||||
/* Set the new type face name */
|
||||
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, (WCHAR*)lParam);
|
||||
snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, pExtLogFont->elfFullName);
|
||||
|
||||
/* Create the new fonts */
|
||||
hDC = GetDC(hwnd);
|
||||
DeleteObject(pData->hCharSetFont);
|
||||
pData->hCharSetFont = CreateFontW(-MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72),
|
||||
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
||||
DEFAULT_PITCH , pData->szTypeFaceName);
|
||||
|
||||
logfont = pExtLogFont->elfLogFont;
|
||||
logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);
|
||||
pData->hCharSetFont = CreateFontIndirectW(&logfont);
|
||||
|
||||
/* Get font format */
|
||||
// FIXME: Get the real font format (OpenType?)
|
||||
|
@ -174,11 +174,8 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
|||
for (i = 0; i < MAX_SIZES; i++)
|
||||
{
|
||||
DeleteObject(pData->hFonts[i]);
|
||||
pData->hFonts[i] = CreateFontW(-MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72),
|
||||
0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
||||
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
|
||||
DEFAULT_PITCH , pData->szTypeFaceName);
|
||||
logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
||||
pData->hFonts[i] = CreateFontIndirectW(&logfont);
|
||||
}
|
||||
|
||||
/* Calculate new page dimensions */
|
||||
|
@ -216,8 +213,13 @@ static LRESULT
|
|||
Display_OnCreate(HWND hwnd)
|
||||
{
|
||||
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;
|
||||
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 */
|
||||
pData = malloc(sizeof(DISPLAYDATA));
|
||||
|
@ -231,18 +233,13 @@ Display_OnCreate(HWND hwnd)
|
|||
pData->nSizes[i] = nSizes[i];
|
||||
}
|
||||
|
||||
pData->hCaptionFont = CreateFontW(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");
|
||||
|
||||
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");
|
||||
pData->hCaptionFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);
|
||||
ExtLogFont.elfLogFont.lfHeight = 12;
|
||||
pData->hSizeFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -398,7 +395,7 @@ DisplayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
return Display_OnVScroll(hwnd, wParam);
|
||||
|
||||
case FVM_SETTYPEFACE:
|
||||
return Display_SetTypeFace(hwnd, lParam);
|
||||
return Display_SetTypeFace(hwnd, (PEXTLOGFONTW)lParam);
|
||||
|
||||
case FVM_SETSTRING:
|
||||
return Display_SetString(hwnd, lParam);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* Size restrictions */
|
||||
#define MAX_STRING 100
|
||||
#define MAX_FORMAT 20
|
||||
#define MAX_SIZES 7
|
||||
#define MAX_SIZES 8
|
||||
|
||||
extern const WCHAR g_szFontDisplayClassName[];
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include "fontview.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
WCHAR g_szTypeFaceName[LF_FULLFACESIZE];
|
||||
LOGFONTW g_LogFontW;
|
||||
EXTLOGFONTW g_ExtLogFontW;
|
||||
|
||||
static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";
|
||||
|
||||
|
@ -117,15 +116,15 @@ WinMain (HINSTANCE hThisInstance,
|
|||
PGFRI GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");
|
||||
|
||||
/* Get the font name */
|
||||
dwSize = sizeof(g_szTypeFaceName);
|
||||
if (!GetFontResourceInfoW(argv[1], &dwSize, g_szTypeFaceName, 1))
|
||||
dwSize = sizeof(g_ExtLogFontW.elfFullName);
|
||||
if (!GetFontResourceInfoW(argv[1], &dwSize, g_ExtLogFontW.elfFullName, 1))
|
||||
{
|
||||
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
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]);
|
||||
return -1;
|
||||
|
@ -162,7 +161,7 @@ WinMain (HINSTANCE hThisInstance,
|
|||
hMainWnd = CreateWindowExW(
|
||||
0, /* Extended possibilites for variation */
|
||||
g_szFontViewClassName, /* Classname */
|
||||
g_szTypeFaceName, /* Title Text */
|
||||
g_ExtLogFontW.elfFullName,/* Title Text */
|
||||
WS_OVERLAPPEDWINDOW, /* default window */
|
||||
CW_USEDEFAULT, /* Windows decides the position */
|
||||
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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Create the quit button */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue