From afd519be0eb304f16897389bf386f44ab22bbb7f Mon Sep 17 00:00:00 2001 From: Huw D M Davies Date: Wed, 3 Apr 2002 21:06:09 +0000 Subject: [PATCH] Fix a few font problems with rotated text and non MM_TEXT mapping modes. Do slightly better with the FF_ flags in WineEngGetTextMetrics. --- dlls/gdi/freetype.c | 55 ++++++++++++++++++++++++++++++++++++++----- dlls/x11drv/xrender.c | 4 +++- include/font.h | 2 +- objects/gdiobj.c | 2 +- 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index 057ead6f486..a29fb29fe7f 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -676,6 +676,7 @@ static LONG load_VDMX(GdiFont font, LONG height) numRecs = GET_BE_WORD(&hdr[2]); numRatios = GET_BE_WORD(&hdr[4]); + TRACE("numRecs = %d numRatios = %d\n", numRecs, numRatios); for(i = 0; i < numRatios; i++) { Ratios ratio; @@ -784,7 +785,7 @@ static LONG load_VDMX(GdiFont font, LONG height) * WineEngCreateFontInstance * */ -GdiFont WineEngCreateFontInstance(HFONT hfont) +GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) { GdiFont ret; Face *face; @@ -893,7 +894,14 @@ not_found: TRACE("Choosen %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName)); - ret->ft_face = OpenFontFile(ret, face->file, plf->lfHeight); + ret->ft_face = OpenFontFile(ret, face->file, + INTERNAL_YWSTODS(dc,plf->lfHeight)); + if (!ret->ft_face) + { + GDI_ReleaseObj(hfont); + free_font( ret ); + return 0; + } if(ret->charset == SYMBOL_CHARSET) pFT_Select_Charmap(ret->ft_face, ft_encoding_symbol); @@ -959,7 +967,11 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf, UINT size; GdiFont font = alloc_font(); - font->ft_face = OpenFontFile(font, face->file, 100); + if (!(font->ft_face = OpenFontFile(font, face->file, 100))) + { + free_font(font); + return; + } memset(&pelf->elfLogFont, 0, sizeof(LOGFONTW)); @@ -1476,8 +1488,39 @@ BOOL WineEngGetTextMetrics(GdiFont font, LPTEXTMETRICW ptm) ptm->tmUnderlined = 0; /* entry in OS2 table */ ptm->tmStruckOut = 0; /* entry in OS2 table */ - /* Yes this is correct; braindead api */ - ptm->tmPitchAndFamily = FT_IS_FIXED_WIDTH(ft_face) ? 0 : TMPF_FIXED_PITCH; + /* Yes TPMF_FIXED_PITCH is correct; braindead api */ + if(!FT_IS_FIXED_WIDTH(ft_face)) + ptm->tmPitchAndFamily = TMPF_FIXED_PITCH; + else + ptm->tmPitchAndFamily = 0; + + switch(pOS2->panose[PAN_FAMILYTYPE_INDEX]) { + case PAN_FAMILY_SCRIPT: + ptm->tmPitchAndFamily |= FF_SCRIPT; + break; + case PAN_FAMILY_DECORATIVE: + case PAN_FAMILY_PICTORIAL: + ptm->tmPitchAndFamily |= FF_DECORATIVE; + break; + case PAN_FAMILY_TEXT_DISPLAY: + if(ptm->tmPitchAndFamily == 0) /* fixed */ + ptm->tmPitchAndFamily = FF_MODERN; + else { + switch(pOS2->panose[PAN_SERIFSTYLE_INDEX]) { + case PAN_SERIF_NORMAL_SANS: + case PAN_SERIF_OBTUSE_SANS: + case PAN_SERIF_PERP_SANS: + ptm->tmPitchAndFamily |= FF_SWISS; + break; + default: + ptm->tmPitchAndFamily |= FF_ROMAN; + } + } + break; + default: + ptm->tmPitchAndFamily |= FF_DONTCARE; + } + if(FT_IS_SCALABLE(ft_face)) ptm->tmPitchAndFamily |= TMPF_VECTOR; if(FT_IS_SFNT(ft_face)) @@ -1726,7 +1769,7 @@ BOOL WineEngInit(void) { return FALSE; } -GdiFont WineEngCreateFontInstance(HFONT hfont) +GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) { return NULL; } diff --git a/dlls/x11drv/xrender.c b/dlls/x11drv/xrender.c index cf2d3b6a3a2..417012426a7 100644 --- a/dlls/x11drv/xrender.c +++ b/dlls/x11drv/xrender.c @@ -578,6 +578,8 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag GetTextMetricsW(hdc, &tm); + tm.tmAscent = INTERNAL_YWSTODS(dc, tm.tmAscent); + tm.tmDescent = INTERNAL_YWSTODS(dc, tm.tmDescent); switch( dc->textAlign & (TA_LEFT | TA_RIGHT | TA_CENTER) ) { case TA_LEFT: if (dc->textAlign & TA_UPDATECP) { @@ -775,7 +777,7 @@ BOOL X11DRV_XRender_ExtTextOut( X11DRV_PDEVICE *physDev, INT x, INT y, UINT flag (unsigned short *)wstr + idx, 1); offset += INTERNAL_XWSTODS(dc, lpDx[idx]); xoff = offset * cosEsc; - yoff = offset * sinEsc; + yoff = offset * -sinEsc; } } diff --git a/include/font.h b/include/font.h index d6e6495eb63..8cfbdb47688 100644 --- a/include/font.h +++ b/include/font.h @@ -87,7 +87,7 @@ extern void FONT_EnumLogFontEx16ToW(const ENUMLOGFONTEX16*, LPENUMLOGFONTEXW); extern LPWSTR FONT_mbtowc(HDC, LPCSTR, INT, INT*, UINT*); -extern GdiFont WineEngCreateFontInstance(HFONT); +extern GdiFont WineEngCreateFontInstance(DC*, HFONT); extern BOOL WineEngDestroyFontInstance(HFONT handle); extern DWORD WineEngEnumFonts(LPLOGFONTW, DEVICEFONTENUMPROC, LPARAM); extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT); diff --git a/objects/gdiobj.c b/objects/gdiobj.c index daaf99e59bf..6bdc1661260 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -1153,7 +1153,7 @@ static HGDIOBJ FONT_SelectObject(DC *dc, HGDIOBJ hFont) if(dc->hFont != hFont || dc->gdiFont == NULL) { if(GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_VA_ABLE) - dc->gdiFont = WineEngCreateFontInstance(hFont); + dc->gdiFont = WineEngCreateFontInstance(dc, hFont); } if(dc->funcs->pSelectFont)