[PATCH 4/7] Implement WineEngLoadScalableFontdir to create a FONTDIR16 for use in a .fot file
Jeremy White
jwhite at codeweavers.com
Wed Apr 23 23:26:29 CDT 2008
---
dlls/gdi32/freetype.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/gdi32/gdi_private.h | 1 +
2 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index a6a7180..b286573 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -5730,6 +5730,107 @@ DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair
return font->total_kern_pairs;
}
+
+/*****************************************************************************
+ * WineEngLoadScalableFontdir
+ * This function will create a FONTDIR16 structure populated with
+ * the data needed in the resource written to a .fot file
+ * as a result of CreateScalableFont.
+ *
+ */
+BOOL WineEngLoadScalableFontdir(LPCSTR filename, FONTDIR16 *fontdir)
+{
+ Face *face = NULL;
+ INT rc;
+ ENUMLOGFONTEXW lf;
+ NEWTEXTMETRICEXW tmW;
+ NEWTEXTMETRICEXA tm;
+ DWORD type;
+ int len;
+ int remainder;
+ char *p;
+ int ret = FALSE;
+
+ TRACE("(%s)\n", filename);
+
+ EnterCriticalSection( &freetype_cs );
+
+ rc = AddFontToList(filename, NULL, 0, NULL, NULL, ADDFONT_IGNORE_GLOBALS, &face);
+ if (rc == 0)
+ goto exit;
+
+ GetEnumStructs(face, &lf, &tmW, &type);
+
+ FONT_NewTextMetricExWToA(&tmW, &tm);
+
+ memset(fontdir, 0, sizeof(*fontdir));
+
+ fontdir->dfVersion = 0x200;
+ fontdir->dfVertRes = 72;
+ fontdir->dfHorizRes = 72;
+
+ fontdir->dfPoints = tm.ntmTm.ntmSizeEM;
+ fontdir->dfAscent = tm.ntmTm.tmAscent;
+ fontdir->dfInternalLeading = tm.ntmTm.tmInternalLeading;
+ fontdir->dfExternalLeading = tm.ntmTm.tmExternalLeading;
+ fontdir->dfItalic = tm.ntmTm.tmItalic;
+ fontdir->dfUnderline = tm.ntmTm.tmUnderlined;
+ fontdir->dfStrikeOut = tm.ntmTm.tmStruckOut;
+ fontdir->dfWeight = tm.ntmTm.tmWeight;
+ fontdir->dfCharSet = tm.ntmTm.tmCharSet;
+ fontdir->dfPitchAndFamily = tm.ntmTm.tmPitchAndFamily;
+ fontdir->dfAvgWidth = tm.ntmTm.tmAveCharWidth;
+ fontdir->dfMaxWidth = tm.ntmTm.tmMaxCharWidth;
+ fontdir->dfFirstChar = tm.ntmTm.tmFirstChar;
+ fontdir->dfLastChar = tm.ntmTm.tmLastChar;
+ fontdir->dfDefaultChar = tm.ntmTm.tmDefaultChar;
+ fontdir->dfBreakChar = tm.ntmTm.tmBreakChar;
+ fontdir->dfPixHeight = tm.ntmTm.ntmCellHeight;
+
+
+ /* Less than ideal; we are apparently using a newer version of
+ the FONTDIR16 structure; the older one had 3 name strings, not
+ 2, at the end. Only the newer one has clear specifications, though,
+ so we'll use that structure, and stash the strings in in what
+ appears to be the correct manner. */
+ p = &(fontdir->szDeviceName[1]);
+ remainder = sizeof(fontdir->szDeviceName) + sizeof(fontdir->szFaceName) - 1;
+
+ len = WideCharToMultiByte(CP_ACP, 0, lf.elfLogFont.lfFaceName, -1, p, remainder, NULL, NULL);
+ if (len == 0 || len >= remainder)
+ goto exit;
+ remainder -= len;
+ p += len;
+
+ len = WideCharToMultiByte(CP_ACP, 0, lf.elfFullName, -1, p, remainder, NULL, NULL);
+ if (len == 0 || len >= remainder)
+ goto exit;
+ remainder -= len;
+ p += len;
+
+ len = WideCharToMultiByte(CP_ACP, 0, lf.elfStyle, -1, p, remainder, NULL, NULL);
+ if (len == 0 || len > remainder)
+ goto exit;
+
+ ret = TRUE;
+
+exit:
+ if (face)
+ {
+ if (face->file) HeapFree(GetProcessHeap(), 0, face->file);
+ if (face->StyleName) HeapFree(GetProcessHeap(), 0, face->StyleName);
+ if (face->family->FamilyName) HeapFree(GetProcessHeap(), 0, (WCHAR *) face->family->FamilyName);
+ if (face->family) HeapFree(GetProcessHeap(), 0, face->family);
+ HeapFree(GetProcessHeap(), 0, face);
+ }
+ LeaveCriticalSection( &freetype_cs );
+
+ return ret;
+}
+
+
+
+
#else /* HAVE_FREETYPE */
/*************************************************************************/
@@ -5884,4 +5985,10 @@ DWORD WineEngGetKerningPairs(GdiFont *font, DWORD cPairs, KERNINGPAIR *kern_pair
return 0;
}
+BOOL WineEngLoadScalableFontdir(LPCSTR filename, FONTDIR16 *fontdir)
+{
+ ERR("called but we don't have FreeType\n");
+ return FALSE;
+}
+
#endif /* HAVE_FREETYPE */
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index c441a31..672dfc2 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -450,6 +450,7 @@ extern BOOL WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW) DECLSPEC_HIDDEN;
extern BOOL WineEngFontIsLinked(GdiFont*) DECLSPEC_HIDDEN;
extern BOOL WineEngInit(void) DECLSPEC_HIDDEN;
extern BOOL WineEngRemoveFontResourceEx(LPCWSTR, DWORD, PVOID) DECLSPEC_HIDDEN;
+extern BOOL WineEngLoadScalableFontdir(LPCSTR filename, FONTDIR16 *fontdir);
/* gdiobj.c */
extern BOOL GDI_Init(void) DECLSPEC_HIDDEN;
More information about the wine-patches
mailing list