gdi32: Add a helper to retrieve the font version.

This commit is contained in:
Huw Davies 2012-03-27 11:48:41 +01:00 committed by Alexandre Julliard
parent e27a633b93
commit 37eb386739
1 changed files with 15 additions and 6 deletions

View File

@ -1568,6 +1568,16 @@ static Family *get_family( FT_Face ft_face, BOOL vertical )
return family; return family;
} }
static inline FT_Fixed get_font_version( FT_Face ft_face )
{
FT_Fixed version = 0;
TT_Header *header;
header = pFT_Get_Sfnt_Table( ft_face, ft_sfnt_head );
if (header) version = header->Font_Revision;
return version;
}
#define ADDFONT_EXTERNAL_FONT 0x01 #define ADDFONT_EXTERNAL_FONT 0x01
#define ADDFONT_FORCE_BITMAP 0x02 #define ADDFONT_FORCE_BITMAP 0x02
@ -1581,7 +1591,6 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
do { do {
TT_OS2 *pOS2; TT_OS2 *pOS2;
TT_Header *pHeader;
Face *face; Face *face;
struct list *face_elem_ptr; struct list *face_elem_ptr;
FT_WinFNT_HeaderRec winfnt_header; FT_WinFNT_HeaderRec winfnt_header;
@ -1589,6 +1598,7 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
FONTSIGNATURE fs; FONTSIGNATURE fs;
My_FT_Bitmap_Size *size = NULL; My_FT_Bitmap_Size *size = NULL;
FT_ULong tmp_size; FT_ULong tmp_size;
FT_Fixed version;
if(!FT_IS_SCALABLE(ft_face)) if(!FT_IS_SCALABLE(ft_face))
size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num; size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num;
@ -1626,16 +1636,15 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
internal_leading = winfnt_header.internal_leading; internal_leading = winfnt_header.internal_leading;
} }
pHeader = pFT_Get_Sfnt_Table(ft_face, ft_sfnt_head); version = get_font_version( ft_face );
LIST_FOR_EACH(face_elem_ptr, &family->faces) { LIST_FOR_EACH(face_elem_ptr, &family->faces) {
face = LIST_ENTRY(face_elem_ptr, Face, entry); face = LIST_ENTRY(face_elem_ptr, Face, entry);
if(!strcmpiW(face->StyleName, StyleW) && if(!strcmpiW(face->StyleName, StyleW) &&
(FT_IS_SCALABLE(ft_face) || ((size->y_ppem == face->size.y_ppem) && !memcmp(&fs, &face->fs, sizeof(fs)) ))) { (FT_IS_SCALABLE(ft_face) || ((size->y_ppem == face->size.y_ppem) && !memcmp(&fs, &face->fs, sizeof(fs)) ))) {
TRACE("Already loaded font %s %s original version is %lx, this version is %lx\n", TRACE("Already loaded font %s %s original version is %lx, this version is %lx\n",
debugstr_w(family->FamilyName), debugstr_w(StyleW), debugstr_w(family->FamilyName), debugstr_w(StyleW),
face->font_version, pHeader ? pHeader->Font_Revision : 0); face->font_version, version);
if(version <= face->font_version) {
if(!pHeader || pHeader->Font_Revision <= face->font_version) {
TRACE("Original font is newer so skipping this one\n"); TRACE("Original font is newer so skipping this one\n");
HeapFree(GetProcessHeap(), 0, StyleW); HeapFree(GetProcessHeap(), 0, StyleW);
return; return;
@ -1673,7 +1682,7 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
if (ft_face->style_flags & FT_STYLE_FLAG_BOLD) if (ft_face->style_flags & FT_STYLE_FLAG_BOLD)
face->ntmFlags |= NTM_BOLD; face->ntmFlags |= NTM_BOLD;
if (face->ntmFlags == 0) face->ntmFlags = NTM_REGULAR; if (face->ntmFlags == 0) face->ntmFlags = NTM_REGULAR;
face->font_version = pHeader ? pHeader->Font_Revision : 0; face->font_version = version;
face->family = family; face->family = family;
face->vertical = vertical; face->vertical = vertical;
face->external = (flags & ADDFONT_EXTERNAL_FONT) ? TRUE : FALSE; face->external = (flags & ADDFONT_EXTERNAL_FONT) ? TRUE : FALSE;