gdi32: return the correct font type,
ntmFlags and PitchAndFamily for Type1 fonts (fixes bug #5877)
Mikolaj Zalewski
mikolajz at google.com
Fri Sep 7 16:38:41 CDT 2007
As I wrote in Bugzilla for Photoshop to work with Type1 fonts after
applying this patch one needs to reinstall Photoshop in a clean
wineprefix - it seems that Photoshop caches some font data.
-------------- next part --------------
From b8510cc104331fc4de4cabf11f3dac0f2ab0b3a6 Mon Sep 17 00:00:00 2001
From: Mikolaj Zalewski <mikolaj at zalewski.pl>
Date: Fri, 7 Sep 2007 14:30:40 -0700
Subject: [PATCH] gdi32: return the correct font type, ntmFlags and PitchAndFamily for Type1 fonts (fixes bug #5877)
---
dlls/gdi32/freetype.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index d223992..5a00542 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -243,6 +243,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 +308,7 @@ struct tagGdiFont {
SHORT yMax;
SHORT yMin;
OUTLINETEXTMETRICW *potm;
+ DWORD ntmFlags;
DWORD total_kern_pairs;
KERNINGPAIR *kern_pairs;
FONTSIGNATURE fs;
@@ -1042,6 +1044,7 @@ #endif /* HAVE_CARBON_CARBON_H */
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 +1193,16 @@ #endif
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, 0x43464620, 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 +2983,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 +3119,7 @@ static void GetEnumStructs(Face *face, L
}
font->name = strdupW(face->family->FamilyName);
+ font->ntmFlags = face->ntmFlags;
memset(&pelf->elfLogFont, 0, sizeof(LOGFONTW));
@@ -3142,13 +3158,18 @@ static void GetEnumStructs(Face *face, L
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 +4136,14 @@ #define TM font->potm->otmTextMetrics
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 +4231,7 @@ static BOOL load_child_font(GdiFont *fon
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.1
More information about the wine-patches
mailing list