- give the fontview class an EXTLOGFONT to set the font, fixes display of wrong font...
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 31 Mar 2008 12:48:40 +0000 (12:48 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Mon, 31 Mar 2008 12:48:40 +0000 (12:48 +0000)
- add font size 8

svn path=/trunk/; revision=32791

rosapps/fontview/display.c
rosapps/fontview/display.h
rosapps/fontview/fontview.c

index dcbd158..d30007b 100644 (file)
@@ -140,7 +140,7 @@ Display_DrawText(HDC hDC, DISPLAYDATA* pData, int nYPos)
 }\r
 \r
 static LRESULT\r
-Display_SetTypeFace(HWND hwnd, LPARAM lParam)\r
+Display_SetTypeFace(HWND hwnd, PEXTLOGFONTW pExtLogFont)\r
 {\r
        DISPLAYDATA* pData;\r
        TEXTMETRIC tm;\r
@@ -148,19 +148,19 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
        RECT rect;\r
        SCROLLINFO si;\r
        int i;\r
+       LOGFONTW logfont;\r
 \r
        /* Set the new type face name */\r
        pData = (DISPLAYDATA*)GetWindowLongPtr(hwnd, GWLP_USERDATA);\r
-       snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, (WCHAR*)lParam);\r
+       snwprintf(pData->szTypeFaceName, LF_FULLFACESIZE, pExtLogFont->elfFullName);\r
 \r
        /* Create the new fonts */\r
        hDC = GetDC(hwnd);\r
        DeleteObject(pData->hCharSetFont);\r
-       pData->hCharSetFont = CreateFontW(-MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72),\r
-                                         0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,\r
-                                         ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
-                                         CLIP_DEFAULT_PRECIS, PROOF_QUALITY,\r
-                                         DEFAULT_PITCH , pData->szTypeFaceName);\r
+\r
+       logfont = pExtLogFont->elfLogFont;\r
+       logfont.lfHeight = -MulDiv(16, GetDeviceCaps(GetDC(NULL), LOGPIXELSY), 72);\r
+       pData->hCharSetFont = CreateFontIndirectW(&logfont);\r
 \r
        /* Get font format */\r
        // FIXME: Get the real font format (OpenType?)\r
@@ -174,11 +174,8 @@ Display_SetTypeFace(HWND hwnd, LPARAM lParam)
        for (i = 0; i < MAX_SIZES; i++)\r
        {\r
                DeleteObject(pData->hFonts[i]);\r
-               pData->hFonts[i] = CreateFontW(-MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72),\r
-                                              0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,\r
-                                              ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
-                                              CLIP_DEFAULT_PRECIS, PROOF_QUALITY,\r
-                                              DEFAULT_PITCH , pData->szTypeFaceName);\r
+               logfont.lfHeight = -MulDiv(pData->nSizes[i], GetDeviceCaps(hDC, LOGPIXELSY), 72);\r
+               pData->hFonts[i] = CreateFontIndirectW(&logfont);\r
        }\r
 \r
        /* Calculate new page dimensions */\r
@@ -216,8 +213,13 @@ static LRESULT
 Display_OnCreate(HWND hwnd)\r
 {\r
        DISPLAYDATA* pData;\r
-       const int nSizes[MAX_SIZES] = {12, 18, 24, 36, 48, 60, 72};\r
+       const int nSizes[MAX_SIZES] = {8, 12, 18, 24, 36, 48, 60, 72};\r
        int i;\r
+       EXTLOGFONTW ExtLogFont = {{50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,\r
+                                 ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
+                                 CLIP_DEFAULT_PRECIS, PROOF_QUALITY,\r
+                                 DEFAULT_PITCH , L"Ms Shell Dlg"},\r
+                                 L"Ms Shell Dlg"};\r
 \r
        /* Create data structure */\r
        pData = malloc(sizeof(DISPLAYDATA));\r
@@ -231,18 +233,13 @@ Display_OnCreate(HWND hwnd)
                pData->nSizes[i] = nSizes[i];\r
        }\r
 \r
-       pData->hCaptionFont = CreateFontW(50, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,\r
-                                         ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
-                                         CLIP_DEFAULT_PRECIS, PROOF_QUALITY,\r
-                                         DEFAULT_PITCH , L"Ms Shell Dlg");\r
-\r
-       pData->hSizeFont = CreateFontW(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,\r
-                                      ANSI_CHARSET, OUT_DEFAULT_PRECIS,\r
-                                      CLIP_DEFAULT_PRECIS, PROOF_QUALITY,\r
-                                      DEFAULT_PITCH , L"Ms Shell Dlg");\r
+       pData->hCaptionFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);\r
+       ExtLogFont.elfLogFont.lfHeight = 12;\r
+       pData->hSizeFont = CreateFontIndirectW(&ExtLogFont.elfLogFont);\r
 \r
        Display_SetString(hwnd, (LPARAM)L"Jackdaws love my big sphinx of quartz. 1234567890");\r
-       Display_SetTypeFace(hwnd, (LPARAM)L"Ms Shell Dlg");\r
+\r
+       Display_SetTypeFace(hwnd, &ExtLogFont);\r
 \r
        return 0;\r
 }\r
@@ -398,7 +395,7 @@ DisplayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                        return Display_OnVScroll(hwnd, wParam);\r
 \r
                case FVM_SETTYPEFACE:\r
-                       return Display_SetTypeFace(hwnd, lParam);\r
+                       return Display_SetTypeFace(hwnd, (PEXTLOGFONTW)lParam);\r
 \r
                case FVM_SETSTRING:\r
                        return Display_SetString(hwnd, lParam);\r
index 6180cf7..687da49 100644 (file)
@@ -8,7 +8,7 @@
 /* Size restrictions */\r
 #define MAX_STRING 100\r
 #define MAX_FORMAT 20\r
-#define MAX_SIZES 7\r
+#define MAX_SIZES 8\r
 \r
 extern const WCHAR g_szFontDisplayClassName[];\r
 \r
index 7881a25..bb791b5 100644 (file)
@@ -23,8 +23,7 @@
 #include "fontview.h"\r
 \r
 HINSTANCE g_hInstance;\r
-WCHAR g_szTypeFaceName[LF_FULLFACESIZE];\r
-LOGFONTW g_LogFontW;\r
+EXTLOGFONTW g_ExtLogFontW;\r
 \r
 static const WCHAR g_szFontViewClassName[] = L"FontViewWClass";\r
 \r
@@ -117,15 +116,15 @@ WinMain (HINSTANCE hThisInstance,
        PGFRI GetFontResourceInfoW = (PGFRI)GetProcAddress(hDLL, "GetFontResourceInfoW");\r
 \r
        /* Get the font name */\r
-       dwSize = sizeof(g_szTypeFaceName);\r
-       if (!GetFontResourceInfoW(argv[1], &dwSize, g_szTypeFaceName, 1))\r
+       dwSize = sizeof(g_ExtLogFontW.elfFullName);\r
+       if (!GetFontResourceInfoW(argv[1], &dwSize, g_ExtLogFontW.elfFullName, 1))\r
        {\r
                ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);\r
                return -1;\r
        }\r
 \r
        dwSize = sizeof(LOGFONTW);\r
-       if (!GetFontResourceInfoW(argv[1], &dwSize, &g_LogFontW, 2))\r
+       if (!GetFontResourceInfoW(argv[1], &dwSize, &g_ExtLogFontW.elfLogFont, 2))\r
        {\r
                ErrorMsgBox(0, IDS_ERROR, IDS_ERROR_NOFONT, argv[1]);\r
                return -1;\r
@@ -162,7 +161,7 @@ WinMain (HINSTANCE hThisInstance,
        hMainWnd = CreateWindowExW(\r
                                0,                                              /* Extended possibilites for variation */\r
                                g_szFontViewClassName,  /* Classname */\r
-                               g_szTypeFaceName,               /* Title Text */\r
+                               g_ExtLogFontW.elfFullName,/* Title Text */\r
                                WS_OVERLAPPEDWINDOW,    /* default window */\r
                                CW_USEDEFAULT,                  /* Windows decides the position */\r
                                CW_USEDEFAULT,                  /* where the window ends up on the screen */\r
@@ -215,7 +214,7 @@ MainWnd_OnCreate(HWND hwnd)
        SendMessage(hDisplay, FVM_SETSTRING, 0, (LPARAM)szString);\r
 \r
        /* Init the display window with the font name */\r
-       SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_LogFontW.lfFaceName);\r
+       SendMessage(hDisplay, FVM_SETTYPEFACE, 0, (LPARAM)&g_ExtLogFontW);\r
        ShowWindow(hDisplay, SW_SHOWNORMAL);\r
 \r
        /* Create the quit button */\r