[PATCH 7/7] Implement support for .fot files created with CreateScalableFontResource
Jeremy White
jwhite at codeweavers.com
Wed Apr 23 23:27:19 CDT 2008
---
dlls/gdi32/freetype.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index b286573..f16a0e9 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -1116,10 +1116,46 @@ static FT_Error load_sfnt_table(FT_Face ft_face, FT_ULong table, FT_Long offset,
return err;
}
+static char *get_scalable_filename(LPCSTR file)
+{
+ HMODULE16 hModule;
+ HRSRC16 hres;
+ HGLOBAL16 hglob;
+ LPSTR fot_path;
+ LPWSTR wide_path;
+ char *ret = NULL;
+ int len;
+
+ hModule = LoadLibrary16(file);
+ if (hModule > 32) {
+ hres = FindResource16(hModule, "#1", (LPCSTR) NE_RSCTYPE_SCALABLE_FONTPATH);
+ if (hres) {
+ hglob = LoadResource16(hModule, hres);
+ if (hglob) {
+ fot_path = LockResource16(hglob);
+ if (fot_path) {
+ len = MultiByteToWideChar(CP_ACP, 0, fot_path, -1, NULL, 0);
+ wide_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP, 0, fot_path, -1, wide_path, len);
+
+ ret = wine_get_unix_file_name(wide_path);
+ HeapFree(GetProcessHeap(), 0, wide_path);
+
+ FreeResource16(hglob);
+ }
+ }
+ }
+ FreeLibrary16(hModule);
+ }
+
+ return ret;
+}
+
#define ADDFONT_EXTERNAL_FONT 0x01
#define ADDFONT_FORCE_BITMAP 0x02
#define ADDFONT_IGNORE_GLOBALS 0x04
+#define ADDFONT_TRY_SCALABLE 0x08
static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_size, char *fake_family, const WCHAR *target_family, DWORD flags, Face **return_face)
{
FT_Face ft_face;
@@ -1169,6 +1205,15 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
{
TRACE("Loading font file %s index %ld\n", debugstr_a(file), face_index);
err = pFT_New_Face(library, file, face_index, &ft_face);
+ if ((flags & ADDFONT_TRY_SCALABLE) && err == FT_Err_Unknown_File_Format) {
+ char *scalable_filename = get_scalable_filename(file);
+ if (scalable_filename) {
+ TRACE("%s appears to be a scalable font file, trying %s\n", debugstr_a(file), scalable_filename);
+ err = AddFontToList(scalable_filename, font_data_ptr, font_data_size, fake_family, target_family, flags & ~ADDFONT_TRY_SCALABLE, return_face);
+ HeapFree(GetProcessHeap(), 0, scalable_filename);
+ return err;
+ }
+ }
} else
{
TRACE("Loading font from ptr %p size %d, index %ld\n", font_data_ptr, font_data_size, face_index);
@@ -2030,7 +2075,7 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
if((unixname = wine_get_unix_file_name(file)))
{
EnterCriticalSection( &freetype_cs );
- ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP);
+ ret = AddFontFileToList(unixname, NULL, NULL, ADDFONT_FORCE_BITMAP | ADDFONT_TRY_SCALABLE);
LeaveCriticalSection( &freetype_cs );
HeapFree(GetProcessHeap(), 0, unixname);
}
More information about the wine-patches
mailing list