Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/gdi32/freetype.c | 112 ++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 74 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index bdd8d97b16d..6a9fad5b5dc 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -274,8 +274,6 @@ typedef struct tagFace { WCHAR *file; dev_t dev; ino_t ino; - void *font_data_ptr; - DWORD font_data_size; FT_Long face_index; FONTSIGNATURE fs; DWORD ntmFlags; @@ -1581,7 +1579,7 @@ static BOOL insert_face_in_family_list( Face *face, Family *family ) debugstr_w(face->full_name), debugstr_w(family->family_name), cursor->font_version, face->font_version );
- if (face->file && face->dev == cursor->dev && face->ino == cursor->ino) + if (face->dev == cursor->dev && face->ino == cursor->ino) { cursor->refcount++; TRACE("Font %s already in list, refcount now %d\n", @@ -2101,8 +2099,7 @@ static inline void get_fontsig( FT_Face ft_face, FONTSIGNATURE *fs ) } }
-static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file, void *font_data_ptr, DWORD font_data_size, - DWORD flags ) +static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file, DWORD flags ) { struct stat st; Face *face = HeapAlloc( GetProcessHeap(), 0, sizeof(*face) ); @@ -2114,22 +2111,11 @@ static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file,
face->dev = 0; face->ino = 0; - if (file) + face->file = towstr( CP_UNIXCP, file ); + if (!stat( file, &st )) { - face->file = towstr( CP_UNIXCP, file ); - face->font_data_ptr = NULL; - face->font_data_size = 0; - if (!stat( file, &st )) - { - face->dev = st.st_dev; - face->ino = st.st_ino; - } - } - else - { - face->file = NULL; - face->font_data_ptr = font_data_ptr; - face->font_data_size = font_data_size; + face->dev = st.st_dev; + face->ino = st.st_ino; }
face->face_index = face_index; @@ -2161,13 +2147,12 @@ static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file, return face; }
-static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr, DWORD font_data_size, - FT_Long face_index, DWORD flags ) +static void AddFaceToList( FT_Face ft_face, const char *file, FT_Long face_index, DWORD flags ) { Face *face; Family *family;
- face = create_face( ft_face, face_index, file, font_data_ptr, font_data_size, flags ); + face = create_face( ft_face, face_index, file, flags ); family = get_family( ft_face, flags & ADDFONT_VERTICAL_FONT );
if (insert_face_in_family_list( face, family )) @@ -2180,34 +2165,25 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr release_family( family ); }
-static FT_Face new_ft_face( const char *file, void *font_data_ptr, DWORD font_data_size, - FT_Long face_index, BOOL allow_bitmap ) +static FT_Face new_ft_face( const char *file, FT_Long face_index, BOOL allow_bitmap ) { FT_Error err; TT_OS2 *pOS2; FT_Face ft_face;
- if (file) - { - TRACE("Loading font file %s index %ld\n", debugstr_a(file), face_index); - err = pFT_New_Face(library, file, face_index, &ft_face); - } - else - { - TRACE("Loading font from ptr %p size %d, index %ld\n", font_data_ptr, font_data_size, face_index); - err = pFT_New_Memory_Face(library, font_data_ptr, font_data_size, face_index, &ft_face); - } + TRACE( "Loading font file %s index %ld\n", debugstr_a(file), face_index ); + err = pFT_New_Face( library, file, face_index, &ft_face );
if (err != 0) { - WARN("Unable to load font %s/%p err = %x\n", debugstr_a(file), font_data_ptr, err); + WARN( "Unable to load font %s err = %x\n", debugstr_a(file), err ); return NULL; }
/* There are too many bugs in FreeType < 2.1.9 for bitmap font support */ if (!FT_IS_SCALABLE( ft_face ) && FT_SimpleVersion < FT_VERSION_VALUE(2, 1, 9)) { - WARN("FreeType version < 2.1.9, skipping bitmap font %s/%p\n", debugstr_a(file), font_data_ptr); + WARN( "FreeType version < 2.1.9, skipping bitmap font %s\n", debugstr_a(file) ); goto fail; }
@@ -2215,7 +2191,7 @@ static FT_Face new_ft_face( const char *file, void *font_data_ptr, DWORD font_da { if (FT_IS_SCALABLE( ft_face ) || !allow_bitmap ) { - WARN("Ignoring font %s/%p\n", debugstr_a(file), font_data_ptr); + WARN( "Ignoring font %s\n", debugstr_a(file) ); goto fail; } } @@ -2225,8 +2201,7 @@ static FT_Face new_ft_face( const char *file, void *font_data_ptr, DWORD font_da !pFT_Get_Sfnt_Table( ft_face, ft_sfnt_hhea ) || !pFT_Get_Sfnt_Table( ft_face, ft_sfnt_head )) { - TRACE("Font %s/%p lacks either an OS2, HHEA or HEAD table.\n" - "Skipping this font.\n", debugstr_a(file), font_data_ptr); + TRACE( "Skipping font %s lacking OS2, HHEA and HEAD tables.\n", debugstr_a(file) ); goto fail; }
@@ -2246,7 +2221,7 @@ static FT_Face new_ft_face( const char *file, void *font_data_ptr, DWORD font_da
if (!ft_face->family_name || !ft_face->style_name) { - TRACE("Font %s/%p lacks either a family or style name\n", debugstr_a(file), font_data_ptr); + TRACE( "Font %s lacks either a family or style name\n", debugstr_a(file) ); goto fail; }
@@ -2256,7 +2231,7 @@ fail: return NULL; }
-static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_size, DWORD flags) +static INT AddFontToList( const char *file, DWORD flags ) { FT_Face ft_face; FT_Long face_index = 0, num_faces; @@ -2276,7 +2251,7 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_ for(cursor = mac_list; *cursor; cursor++) { had_one = TRUE; - AddFontToList(*cursor, NULL, 0, flags); + AddFontToList( *cursor, flags ); HeapFree(GetProcessHeap(), 0, *cursor); } HeapFree(GetProcessHeap(), 0, mac_list); @@ -2289,7 +2264,7 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_ do { FONTSIGNATURE fs;
- ft_face = new_ft_face( file, font_data_ptr, font_data_size, face_index, flags & ADDFONT_ALLOW_BITMAP ); + ft_face = new_ft_face( file, face_index, flags & ADDFONT_ALLOW_BITMAP ); if (!ft_face) return 0;
if(ft_face->family_name[0] == '.') /* Ignore fonts with names beginning with a dot */ @@ -2299,14 +2274,13 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_ return 0; }
- AddFaceToList(ft_face, file, font_data_ptr, font_data_size, face_index, flags); + AddFaceToList( ft_face, file, face_index, flags ); ++ret;
get_fontsig(ft_face, &fs); if (fs.fsCsb[0] & FS_DBCS_MASK) { - AddFaceToList(ft_face, file, font_data_ptr, font_data_size, face_index, - flags | ADDFONT_VERTICAL_FONT); + AddFaceToList( ft_face, file, face_index, flags | ADDFONT_VERTICAL_FONT ); ++ret; }
@@ -2323,7 +2297,7 @@ static int add_font_resource( const WCHAR *file, DWORD flags )
if (unixname) { - ret = AddFontToList( unixname, NULL, 0, flags ); + ret = AddFontToList( unixname, flags ); HeapFree( GetProcessHeap(), 0, unixname ); } return ret; @@ -2344,7 +2318,6 @@ static int remove_font_resource( const WCHAR *file, DWORD flags ) family->refcount++; LIST_FOR_EACH_ENTRY_SAFE( face, face_next, &family->faces, Face, entry ) { - if (!face->file) continue; if (LOWORD(face->flags) != LOWORD(flags)) continue; if (st.st_dev == face->dev && st.st_ino == face->ino) { @@ -2811,7 +2784,7 @@ static BOOL ReadFontDir(const char *dirname, BOOL external_fonts) { DWORD addfont_flags = ADDFONT_ADD_TO_CACHE; if(external_fonts) addfont_flags |= ADDFONT_EXTERNAL_FONT; - AddFontToList(path, NULL, 0, addfont_flags); + AddFontToList( path, addfont_flags ); } } closedir(dir); @@ -2946,8 +2919,7 @@ static void load_fontconfig_fonts(void) if(len < 4) continue; ext = &file[ len - 3 ]; if(_strnicmp(ext, "pfa", -1) && _strnicmp(ext, "pfb", -1)) - AddFontToList(file, NULL, 0, - ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE | ADDFONT_AA_FLAGS(aa_flags) ); + AddFontToList( file, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE | ADDFONT_AA_FLAGS( aa_flags ) ); } pFcFontSetDestroy(fontset); pFcPatternDestroy(pat); @@ -2966,7 +2938,7 @@ static void load_mac_font_callback(const void *value, void *context) if (path && CFStringGetFileSystemRepresentation(pathStr, path, len)) { TRACE("font file %s\n", path); - AddFontToList(path, NULL, 0, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE); + AddFontToList( path, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE ); } HeapFree(GetProcessHeap(), 0, path); } @@ -3472,7 +3444,7 @@ static void GetEnumStructs(Face *face, const WCHAR *family_name, LPENUMLOGFONTEX
static BOOL get_fontdir( const char *unix_name, struct fontdir *fd ) { - FT_Face ft_face = new_ft_face( unix_name, NULL, 0, 0, FALSE ); + FT_Face ft_face = new_ft_face( unix_name, 0, FALSE ); Face *face; WCHAR *family_name; ENUMLOGFONTEXW elf; @@ -3480,7 +3452,7 @@ static BOOL get_fontdir( const char *unix_name, struct fontdir *fd ) DWORD type;
if (!ft_face) return FALSE; - face = create_face( ft_face, 0, unix_name, NULL, 0, 0 ); + face = create_face( ft_face, 0, unix_name, 0 ); family_name = ft_face_get_family_name( ft_face, GetSystemDefaultLCID() ); pFT_Done_Face( ft_face );
@@ -4553,28 +4525,21 @@ static FT_Face OpenFontFace(GdiFont *font, Face *face, LONG width, LONG height) FT_Error err; FT_Face ft_face; void *data_ptr; + char *filename; DWORD data_size;
- TRACE("%s/%p, %ld, %d x %d\n", debugstr_w(face->file), face->font_data_ptr, face->face_index, width, height); + TRACE( "%s, %d x %d\n", debugstr_w(face->file), width, height );
- if (face->file) - { - char *filename = strWtoA( CP_UNIXCP, face->file ); - font->mapping = map_font_file( filename ); - HeapFree( GetProcessHeap(), 0, filename ); - if (!font->mapping) - { - WARN("failed to map %s\n", debugstr_w(face->file)); - return 0; - } - data_ptr = font->mapping->data; - data_size = font->mapping->size; - } - else + filename = strWtoA( CP_UNIXCP, face->file ); + font->mapping = map_font_file( filename ); + HeapFree( GetProcessHeap(), 0, filename ); + if (!font->mapping) { - data_ptr = face->font_data_ptr; - data_size = face->font_data_size; + WARN( "failed to map %s\n", debugstr_w(face->file) ); + return 0; } + data_ptr = font->mapping->data; + data_size = font->mapping->size;
err = pFT_New_Memory_Face(library, data_ptr, data_size, face->face_index, &ft_face); if(err) { @@ -5844,8 +5809,7 @@ found_face: else ret->charset = get_nearest_charset( family->family_name, face, &ret->codepage );
- TRACE( "Chosen: %s (%s/%p:%ld)\n", debugstr_w(face->full_name), debugstr_w(face->file), - face->font_data_ptr, face->face_index ); + TRACE( "Chosen: %s (%s:%ld)\n", debugstr_w(face->full_name), debugstr_w(face->file), face->face_index );
ret->aveWidth = height ? lf.lfWidth : 0;