https://git.reactos.org/?p=reactos.git;a=commitdiff;h=183e1eb71bf4df393ecc8…
commit 183e1eb71bf4df393ecc84d49e524cfa1ff05c4a
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Sep 12 09:40:48 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Sep 12 09:40:48 2020 +0900
[FONTEXT] Initial implementation of CFontExt::DoGetFontTitle (#3127)
This PR is a preparation of fonts folder implementation. CORE-12861
---
dll/shellext/fontext/CFontExt.cpp | 36 ++++++++++++++++++++++++++----------
dll/shellext/fontext/CFontExt.hpp | 2 +-
sdk/include/reactos/undocgdi.h | 32 ++++++++++++++++++++++----------
3 files changed, 49 insertions(+), 21 deletions(-)
diff --git a/dll/shellext/fontext/CFontExt.cpp b/dll/shellext/fontext/CFontExt.cpp
index c157104c7e9..03d03f420b1 100644
--- a/dll/shellext/fontext/CFontExt.cpp
+++ b/dll/shellext/fontext/CFontExt.cpp
@@ -7,6 +7,7 @@
*/
#include "precomp.h"
+#include "undocgdi.h" // for GetFontResourceInfoW
WINE_DEFAULT_DEBUG_CHANNEL(fontext);
@@ -454,12 +455,8 @@ STDMETHODIMP CFontExt::DragEnter(IDataObject* pDataObj, DWORD
grfKeyState, POINT
if (FAILED_UNEXPECTEDLY(hr))
return hr;
-#if 1 // Please implement DoGetFontTitle
- return DRAGDROP_S_CANCEL;
-#else
*pdwEffect = DROPEFFECT_COPY;
return S_OK;
-#endif
}
STDMETHODIMP CFontExt::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
@@ -567,8 +564,8 @@ HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR
pszFontsDir, HK
WCHAR szDestFile[MAX_PATH];
LPCWSTR pszFileTitle = PathFindFileName(pszFontPath);
- WCHAR szFontName[512];
- if (!DoGetFontTitle(pszFontPath, szFontName))
+ CStringW strFontName;
+ if (!DoGetFontTitle(pszFontPath, strFontName))
return E_FAIL;
RemoveFontResourceW(pszFileTitle);
@@ -581,7 +578,7 @@ HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR
pszFontsDir, HK
return E_FAIL;
}
- if (!AddFontResourceW(pszFileTitle))
+ if (!AddFontResourceW(szDestFile))
{
ERR("AddFontResourceW('%S') failed\n", pszFileTitle);
DeleteFileW(szDestFile);
@@ -589,7 +586,8 @@ HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR
pszFontsDir, HK
}
DWORD cbData = (wcslen(pszFileTitle) + 1) * sizeof(WCHAR);
- LONG nError = RegSetValueExW(hkeyFonts, szFontName, 0, REG_SZ, (const BYTE
*)szFontName, cbData);
+ LONG nError = RegSetValueExW(hkeyFonts, strFontName, 0, REG_SZ,
+ (const BYTE *)pszFileTitle, cbData);
if (nError)
{
ERR("RegSetValueExW failed with %ld\n", nError);
@@ -601,8 +599,26 @@ HRESULT CFontExt::DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR
pszFontsDir, HK
return S_OK;
}
-HRESULT CFontExt::DoGetFontTitle(LPCWSTR pszFontPath, LPCWSTR pszFontName)
+HRESULT
+CFontExt::DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName)
{
- // TODO:
+ DWORD cbInfo = 0;
+ BOOL ret = GetFontResourceInfoW(pszFontPath, &cbInfo, NULL, 1);
+ if (!ret || !cbInfo)
+ {
+ ERR("GetFontResourceInfoW failed\n");
+ return E_FAIL;
+ }
+
+ LPWSTR pszBuffer = strFontName.GetBuffer(cbInfo / sizeof(WCHAR));
+ ret = GetFontResourceInfoW(pszFontPath, &cbInfo, pszBuffer, 1);
+ strFontName.ReleaseBuffer();
+ if (ret)
+ {
+ TRACE("pszFontName: %S\n", (LPCWSTR)strFontName);
+ return S_OK;
+ }
+
+ ERR("GetFontResourceInfoW failed\n");
return E_FAIL;
}
diff --git a/dll/shellext/fontext/CFontExt.hpp b/dll/shellext/fontext/CFontExt.hpp
index 6e3a178042d..ba868628957 100644
--- a/dll/shellext/fontext/CFontExt.hpp
+++ b/dll/shellext/fontext/CFontExt.hpp
@@ -93,5 +93,5 @@ public:
END_COM_MAP()
HRESULT DoInstallFontFile(LPCWSTR pszFontPath, LPCWSTR pszFontsDir, HKEY hkeyFonts);
- HRESULT DoGetFontTitle(LPCWSTR pszFontPath, LPCWSTR pszFontName);
+ HRESULT DoGetFontTitle(IN LPCWSTR pszFontPath, OUT CStringW& strFontName);
};
diff --git a/sdk/include/reactos/undocgdi.h b/sdk/include/reactos/undocgdi.h
index 9abdbef9443..5826d4e9540 100644
--- a/sdk/include/reactos/undocgdi.h
+++ b/sdk/include/reactos/undocgdi.h
@@ -2,6 +2,10 @@
#ifndef _UNDOCGDI_H
#define _UNDOCGDI_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define DS_TILE 0x2
#define DS_TRANSPARENTALPHA 0x4
#define DS_TRANSPARENTCLR 0x8
@@ -26,19 +30,27 @@ typedef struct GDI_DRAW_STREAM_TAG
DWORD crTransparent; // transparent color.
} GDI_DRAW_STREAM, *PGDI_DRAW_STREAM;
-BOOL
-WINAPI
-GdiDrawStream(HDC dc, ULONG l, PGDI_DRAW_STREAM pDS);
+BOOL WINAPI GdiDrawStream(HDC dc, ULONG l, PGDI_DRAW_STREAM pDS);
-BOOL
-WINAPI
+BOOL WINAPI
GetTextExtentExPointWPri(
HDC hdc,
- LPCWSTR lpwsz,
+ LPCWSTR lpwsz,
INT cwc,
- INT dxMax,
- LPINT pcCh,
- LPINT pdxOut,
+ INT dxMax,
+ LPINT pcCh,
+ LPINT pdxOut,
LPSIZE psize);
-#endif
\ No newline at end of file
+BOOL WINAPI
+GetFontResourceInfoW(
+ _In_z_ LPCWSTR lpFileName,
+ _Inout_ DWORD *pdwBufSize,
+ _Out_writes_to_opt_(*pdwBufSize, 1) PVOID lpBuffer,
+ _In_ DWORD dwType);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif