[ros-diffs] [tkreuzer] 27148: - use LOGFONTW structure from GetFontResourceInfo for face name - use LF_FULLFACESIZE - some cleanup

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Mon Jun 11 22:38:55 CEST 2007


Author: tkreuzer
Date: Tue Jun 12 00:38:55 2007
New Revision: 27148

URL: http://svn.reactos.org/svn/reactos?rev=27148&view=rev
Log:
- use LOGFONTW structure from GetFontResourceInfo for face name
- use LF_FULLFACESIZE
- some cleanup

Modified:
    trunk/rosapps/fontview/display.c
    trunk/rosapps/fontview/display.h
    trunk/rosapps/fontview/fontview.c

Modified: trunk/rosapps/fontview/display.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/display.c?rev=27148&r1=27147&r2=27148&view=diff
==============================================================================
--- trunk/rosapps/fontview/display.c (original)
+++ trunk/rosapps/fontview/display.c Tue Jun 12 00:38:55 2007
@@ -35,7 +35,7 @@
 typedef struct
 {
 	int nPageHeight;
-	WCHAR szTypeFaceName[MAX_TYPEFACENAME];
+	WCHAR szTypeFaceName[LF_FULLFACESIZE];
 	WCHAR szFormat[MAX_FORMAT];
 	WCHAR szString[MAX_STRING];
 
@@ -81,9 +81,8 @@
 	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 @@
 		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 @@
 
 	/* 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 @@
 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 */

Modified: trunk/rosapps/fontview/display.h
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/display.h?rev=27148&r1=27147&r2=27148&view=diff
==============================================================================
--- trunk/rosapps/fontview/display.h (original)
+++ trunk/rosapps/fontview/display.h Tue Jun 12 00:38:55 2007
@@ -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[];

Modified: trunk/rosapps/fontview/fontview.c
URL: http://svn.reactos.org/svn/reactos/trunk/rosapps/fontview/fontview.c?rev=27148&r1=27147&r2=27148&view=diff
==============================================================================
--- trunk/rosapps/fontview/fontview.c (original)
+++ trunk/rosapps/fontview/fontview.c Tue Jun 12 00:38:55 2007
@@ -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(
@@ -117,6 +119,13 @@
 	/* Get the font name */
 	dwSize = sizeof(g_szTypeFaceName);
 	if (!GetFontResourceInfoW(argv[1], &dwSize, g_szTypeFaceName, 1))
+	{
+		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
+		return -1;
+	}
+
+	dwSize = sizeof(LOGFONTW);
+	if (!GetFontResourceInfoW(argv[1], &dwSize, &g_LogFontW, 2))
 	{
 		ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);
 		return -1;
@@ -206,7 +215,7 @@
 	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 @@
 			}
 			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);
-    }
-
-    return 0;
+		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);
+	}
+
+	return 0;
 }
 
 /* EOF */




More information about the Ros-diffs mailing list