mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
- use LOGFONTW structure from GetFontResourceInfo for face name
- use LF_FULLFACESIZE - some cleanup svn path=/trunk/; revision=27148
This commit is contained in:
parent
07e6389f6c
commit
1b70c2f495
3 changed files with 24 additions and 18 deletions
|
@ -35,7 +35,7 @@ LRESULT CALLBACK DisplayProc(HWND, UINT, WPARAM, LPARAM);
|
|||
typedef struct
|
||||
{
|
||||
int nPageHeight;
|
||||
WCHAR szTypeFaceName[MAX_TYPEFACENAME];
|
||||
WCHAR szTypeFaceName[LF_FULLFACESIZE];
|
||||
WCHAR szFormat[MAX_FORMAT];
|
||||
WCHAR szString[MAX_STRING];
|
||||
|
||||
|
@ -81,9 +81,8 @@ Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos)
|
|||
HFONT hOldFont;
|
||||
TEXTMETRIC tm;
|
||||
int i, y;
|
||||
const int nSizes[7] = {12, 18, 24, 36, 48, 60, 72};
|
||||
WCHAR szSize[5];
|
||||
WCHAR szCaption[MAX_TYPEFACENAME + 20];
|
||||
WCHAR szCaption[LF_FULLFACESIZE + 20];
|
||||
|
||||
/* This is the location on the DC where we draw */
|
||||
y = -nYPos;
|
||||
|
@ -132,7 +131,7 @@ Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos)
|
|||
GetTextMetrics(hDC, &tm);
|
||||
y += tm.tmHeight + 1;
|
||||
SelectObject(hDC, pData->hSizeFont);
|
||||
swprintf(szSize, L"%d", nSizes[i]);
|
||||
swprintf(szSize, L"%d", pData->nSizes[i]);
|
||||
TextOutW(hDC, 0, y - 13 - tm.tmDescent, szSize, wcslen(szSize));
|
||||
}
|
||||
SelectObject(hDC, hOldFont);
|
||||
|
@ -152,7 +151,7 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
|
|||
|
||||
/* Set the new type face name */
|
||||
pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
snwprintf(pData->szTypeFaceName, MAX_TYPEFACENAME, (WCHAR*)lParam);
|
||||
snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, (WCHAR*)lParam);
|
||||
|
||||
/* Create the new fonts */
|
||||
hDC = GetDC(hwnd);
|
||||
|
@ -217,7 +216,7 @@ static LRESULT
|
|||
Display_OnCreate(HWND hwnd)
|
||||
{
|
||||
DISPLAYDATA* pData;
|
||||
const int nSizes[7] = {12, 18, 24, 36, 48, 60, 72};
|
||||
const int nSizes[MAX_SIZES] = {12, 18, 24, 36, 48, 60, 72};
|
||||
int i;
|
||||
|
||||
/* Create data structure */
|
||||
|
|
|
@ -7,9 +7,7 @@
|
|||
|
||||
/* Size restrictions */
|
||||
#define MAX_STRING 100
|
||||
#define MAX_TYPEFACENAME 32
|
||||
#define MAX_FORMAT 20
|
||||
|
||||
#define MAX_SIZES 7
|
||||
|
||||
extern const WCHAR g_szFontDisplayClassName[];
|
||||
|
|
|
@ -23,11 +23,13 @@
|
|||
#include "fontview.h"
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
WCHAR g_szTypeFaceName[MAX_TYPEFACENAME];
|
||||
WCHAR g_szTypeFaceName[LF_FULLFACESIZE];
|
||||
LOGFONTW g_LogFontW;
|
||||
|
||||
static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";
|
||||
|
||||
/* Tye definition for the GetFontResourceInfo function */
|
||||
typedef BOOL (WINAPI *PGFRI)(LPCWSTR, DWORD *, LPWSTR, DWORD);
|
||||
typedef BOOL (WINAPI *PGFRI)(LPCWSTR, DWORD *, LPVOID, DWORD);
|
||||
|
||||
DWORD
|
||||
FormatString(
|
||||
|
@ -122,6 +124,13 @@ WinMain (HINSTANCE hThisInstance,
|
|||
return -1;
|
||||
}
|
||||
|
||||
dwSize = sizeof(LOGFONTW);
|
||||
if (!GetFontResourceInfoW(argv[1], &dwSize, &g_LogFontW, 2))
|
||||
{
|
||||
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!Display_InitClass(hThisInstance))
|
||||
{
|
||||
ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOCLASS);
|
||||
|
@ -206,7 +215,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_szTypeFaceName);
|
||||
SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_LogFontW.lfFaceName);
|
||||
ShowWindow(hDisplay, SW_SHOWNORMAL);
|
||||
|
||||
/* Create the quit button */
|
||||
|
@ -303,15 +312,15 @@ MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
|
||||
break;
|
||||
|
||||
default: /* for messages that we don't deal with */
|
||||
return DefWindowProcW(hwnd, message, wParam, lParam);
|
||||
}
|
||||
default: /* for messages that we don't deal with */
|
||||
return DefWindowProcW(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue