gdi32: return the correct font type, ntmFlags and PitchAndFamily
for Type1 fonts (improved, fixes bug #5877)
Mikołaj Zalewski
mikolaj at zalewski.pl
Sat Sep 8 19:20:25 CDT 2007
As suggested by Dmitry the table id is now a symbolic constant. However
I didn't included the tttags.h but defined the constant myself as I see
that every freetype header is checked by configure and included only if
it is available. Thus in case it is not available we would either need
an #ifdef in AddFileToList (what IMHO wouldn't be nice) or in such a
case define the symbol ourselfs. But if we will need to define the
symbol then why to include the header?
-------------- next part --------------
>From 6555c9c60b98c5e349058048e6a926844fbf9bdf Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Sat, 8 Sep 2007 16:52:45 -0700
Subject: [PATCH] gdi32: return the correct font type, ntmFlags and PitchAndFamily for Type1 fonts (fixes bug #5877)
---
dlls/gdi32/freetype.c | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index d223992..1e08d13 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -137,6 +137,8 @@ typedef enum
} FT_TrueTypeEngineType;
#endif
+#define WINEENG_SFNTTAG_CFF 0x43464620 /* stores the outline for Type1 OTF fonts */
+
static FT_Library library = 0;
typedef struct
{
@@ -243,6 +245,7 @@ typedef struct tagFace {
BOOL Bold;
FONTSIGNATURE fs;
FONTSIGNATURE fs_links;
+ DWORD ntmFlags; /* Only some bits stored here. Others are computed on the fly */
FT_Fixed font_version;
BOOL scalable;
Bitmap_Size size; /* set if face is a bitmap */
@@ -307,6 +310,7 @@ struct tagGdiFont {
SHORT yMax;
SHORT yMin;
OUTLINETEXTMETRICW *potm;
+ DWORD ntmFlags;
DWORD total_kern_pairs;
KERNINGPAIR *kern_pairs;
FONTSIGNATURE fs;
@@ -1042,6 +1046,7 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
bitmap_num = 0;
do {
My_FT_Bitmap_Size *size = NULL;
+ FT_ULong tmp_size;
if(!FT_IS_SCALABLE(ft_face))
size = (My_FT_Bitmap_Size *)ft_face->available_sizes + bitmap_num;
@@ -1190,6 +1195,16 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_
face->scalable = FALSE;
}
+ /* check for the presence of the 'CFF ' table to check if the font is Type1 */
+ tmp_size = 0;
+ if (pFT_Load_Sfnt_Table && !pFT_Load_Sfnt_Table(ft_face, WINEENG_SFNTTAG_CFF, 0, NULL, &tmp_size))
+ {
+ TRACE("Font %s/%p is OTF Type1\n", wine_dbgstr_a(file), font_data_ptr);
+ face->ntmFlags = NTM_PS_OPENTYPE;
+ }
+ else
+ face->ntmFlags = 0;
+
TRACE("fsCsb = %08x %08x/%08x %08x %08x %08x\n",
face->fs.fsCsb[0], face->fs.fsCsb[1],
face->fs.fsUsb[0], face->fs.fsUsb[1],
@@ -2970,6 +2985,8 @@ found:
return 0;
}
+ ret->ntmFlags = face->ntmFlags;
+
if (ret->charset == SYMBOL_CHARSET &&
!pFT_Select_Charmap(ret->ft_face, FT_ENCODING_MS_SYMBOL)) {
/* No ops */
@@ -3104,6 +3121,7 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
}
font->name = strdupW(face->family->FamilyName);
+ font->ntmFlags = face->ntmFlags;
memset(&pelf->elfLogFont, 0, sizeof(LOGFONTW));
@@ -3142,13 +3160,18 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
pelf->elfLogFont.lfClipPrecision = CLIP_STROKE_PRECIS;
pelf->elfLogFont.lfQuality = DRAFT_QUALITY;
- *ptype = ptm->tmPitchAndFamily & TMPF_TRUETYPE ? TRUETYPE_FONTTYPE : 0;
+ *ptype = 0;
+ if (ptm->tmPitchAndFamily & TMPF_TRUETYPE)
+ *ptype |= TRUETYPE_FONTTYPE;
+ if (ptm->tmPitchAndFamily & TMPF_DEVICE)
+ *ptype |= DEVICE_FONTTYPE;
if(!(ptm->tmPitchAndFamily & TMPF_VECTOR))
*ptype |= RASTER_FONTTYPE;
pntm->ntmTm.ntmFlags = ptm->tmItalic ? NTM_ITALIC : 0;
if(ptm->tmWeight > 550) pntm->ntmTm.ntmFlags |= NTM_BOLD;
if(pntm->ntmTm.ntmFlags == 0) pntm->ntmTm.ntmFlags = NTM_REGULAR;
+ pntm->ntmTm.ntmFlags |= face->ntmFlags;
pntm->ntmTm.ntmCellHeight = pntm->ntmTm.tmHeight;
pntm->ntmTm.ntmAvgWidth = pntm->ntmTm.tmAveCharWidth;
@@ -4115,8 +4138,14 @@ UINT WineEngGetOutlineTextMetrics(GdiFont *font, UINT cbSize,
if(FT_IS_SCALABLE(ft_face))
TM.tmPitchAndFamily |= TMPF_VECTOR;
+
if(FT_IS_SFNT(ft_face))
- TM.tmPitchAndFamily |= TMPF_TRUETYPE;
+ {
+ if (font->ntmFlags & NTM_PS_OPENTYPE)
+ TM.tmPitchAndFamily |= TMPF_DEVICE;
+ else
+ TM.tmPitchAndFamily |= TMPF_TRUETYPE;
+ }
TM.tmCharSet = font->charset;
#undef TM
@@ -4204,6 +4233,7 @@ static BOOL load_child_font(GdiFont *font, CHILD_FONT *child)
return FALSE;
}
+ child->font->ntmFlags = child->face->ntmFlags;
child->font->orientation = font->orientation;
hfontlist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hfontlist));
hfontlist->hfont = CreateFontIndirectW(&font->font_desc.lf);
--
1.4.4.2
More information about the wine-patches
mailing list