Commit d26462b5 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Move the font file information out of freetype.c.

parent 82c140f1
......@@ -422,9 +422,37 @@ void free_gdi_font( struct gdi_font *font )
{
if (font->private) font_funcs->destroy_font( font );
free_font_handle( font->handle );
HeapFree( GetProcessHeap(), 0, font->fileinfo );
HeapFree( GetProcessHeap(), 0, font );
}
/* Undocumented structure filled in by GetFontFileInfo */
struct font_fileinfo
{
FILETIME writetime;
LARGE_INTEGER size;
WCHAR path[1];
};
void set_gdi_font_file_info( struct gdi_font *font, const WCHAR *file, SIZE_T data_size )
{
WIN32_FILE_ATTRIBUTE_DATA info;
int len = 0;
if (file) len = strlenW( file );
if (!(font->fileinfo = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
offsetof( struct font_fileinfo, path[len + 1] ))))
return;
if (file && GetFileAttributesExW( file, GetFileExInfoStandard, &info ))
{
font->fileinfo->writetime = info.ftLastWriteTime;
font->fileinfo->size.QuadPart = (LONGLONG)info.nFileSizeHigh << 32 | info.nFileSizeLow;
strcpyW( font->fileinfo->path, file );
}
else font->fileinfo->size.QuadPart = data_size;
}
/* font cache */
static struct list gdi_font_list = LIST_INIT( gdi_font_list );
......@@ -5179,12 +5207,19 @@ BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_filei
if (!needed) needed = &required_size;
if (!font_funcs || !font)
if (!font)
{
*needed = 0;
return FALSE;
}
return font_funcs->pGetFontFileInfo( font, unknown, info, size, needed );
*needed = sizeof(*info) + strlenW( font->fileinfo->path ) * sizeof(WCHAR);
if (*needed > size)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
memcpy( info, font->fileinfo, *needed );
return TRUE;
}
struct realization_info
......
......@@ -350,7 +350,6 @@ struct tagGdiFont {
VOID *GSUB_Table;
const VOID *vert_feature;
ULONG ttc_item_offset; /* 0 if font is not a part of TrueType collection */
struct font_fileinfo *fileinfo;
};
static inline GdiFont *get_font_ptr( struct gdi_font *font ) { return font->private; }
......@@ -4112,7 +4111,6 @@ static void CDECL freetype_destroy_font( struct gdi_font *gdi_font )
HeapFree(GetProcessHeap(), 0, child);
}
HeapFree(GetProcessHeap(), 0, font->fileinfo);
if (font->ft_face) pFT_Done_Face(font->ft_face);
if (font->mapping) unmap_font_file( font->mapping );
HeapFree(GetProcessHeap(), 0, font->kern_pairs);
......@@ -4767,30 +4765,6 @@ static const VOID * get_GSUB_vert_feature(const GdiFont *font)
return feature;
}
static void fill_fileinfo_from_face( GdiFont *font, Face *face )
{
WIN32_FILE_ATTRIBUTE_DATA info;
int len;
if (!face->file)
{
font->fileinfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*font->fileinfo));
font->fileinfo->size.QuadPart = face->font_data_size;
return;
}
len = strlenW(face->file);
font->fileinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*font->fileinfo) + len * sizeof(WCHAR));
if (GetFileAttributesExW(face->file, GetFileExInfoStandard, &info))
{
font->fileinfo->writetime = info.ftLastWriteTime;
font->fileinfo->size.QuadPart = (LONGLONG)info.nFileSizeHigh << 32 | info.nFileSizeLow;
strcpyW(font->fileinfo->path, face->file);
}
else
memset(font->fileinfo, 0, sizeof(*font->fileinfo) + len * sizeof(WCHAR));
}
/*************************************************************
* freetype_SelectFont
*/
......@@ -5183,7 +5157,7 @@ found_face:
goto done;
}
fill_fileinfo_from_face( ret, face );
set_gdi_font_file_info( gdi_font, face->file, face->font_data_size );
ret->ntmFlags = face->ntmFlags;
pick_charmap( ret->ft_face, ret->charset );
......@@ -7969,26 +7943,6 @@ static BOOL CDECL freetype_GetFontFileData( struct gdi_font *gdi_font, DWORD unk
}
/*************************************************************************
* freetype_GetFontFileInfo
*/
static BOOL CDECL freetype_GetFontFileInfo( struct gdi_font *gdi_font, DWORD unknown,
struct font_fileinfo *info, SIZE_T size, SIZE_T *needed )
{
const GdiFont *font = get_font_ptr( gdi_font );
*needed = sizeof(*info) + strlenW(font->fileinfo->path) * sizeof(WCHAR);
if (*needed > size)
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
/* path is included too */
memcpy(info, font->fileinfo, *needed);
return TRUE;
}
/*************************************************************************
* Kerning support for TrueType fonts
*/
......@@ -8261,7 +8215,6 @@ static const struct font_backend_funcs font_funcs =
freetype_AddFontMemResourceEx,
freetype_CreateScalableFontResource,
freetype_GetFontFileData,
freetype_GetFontFileInfo,
freetype_alloc_font,
freetype_destroy_font
};
......
......@@ -301,14 +301,6 @@ struct char_width_info
INT unk; /* unknown */
};
/* Undocumented structure filled in by GetFontFileInfo */
struct font_fileinfo
{
FILETIME writetime;
LARGE_INTEGER size;
WCHAR path[1];
};
typedef struct { FLOAT eM11, eM12, eM21, eM22; } FMAT2;
struct gdi_font
......@@ -324,6 +316,7 @@ struct gdi_font
LOGFONTW lf;
FMAT2 matrix;
BOOL can_use_bitmap;
struct font_fileinfo *fileinfo;
};
struct font_backend_funcs
......@@ -356,8 +349,6 @@ struct font_backend_funcs
LPCWSTR font_file, LPCWSTR font_path );
BOOL (CDECL *pGetFontFileData)( struct gdi_font *font, DWORD unknown, UINT64 offset,
void *buff, DWORD buff_size );
BOOL (CDECL *pGetFontFileInfo)( struct gdi_font *font, DWORD unknown,
struct font_fileinfo *info, SIZE_T size, SIZE_T *needed );
BOOL (CDECL *alloc_font)( struct gdi_font *font );
void (CDECL *destroy_font)( struct gdi_font *font );
......@@ -368,6 +359,7 @@ extern void free_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;
extern void cache_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;
extern struct gdi_font *find_cached_gdi_font( const LOGFONTW *lf, const FMAT2 *matrix,
BOOL can_use_bitmap ) DECLSPEC_HIDDEN;
extern void set_gdi_font_file_info( struct gdi_font *font, const WCHAR *file, SIZE_T data_size ) DECLSPEC_HIDDEN;
extern void font_init(void) DECLSPEC_HIDDEN;
/* freetype.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment