Huw Davies : wineps.drv: Calculate the font size directly from the logfont.
Alexandre Julliard
julliard at winehq.org
Thu Apr 22 11:24:02 CDT 2010
Module: wine
Branch: master
Commit: 93f970ce7b086a31eb6e8faf1e17a5b2982c922f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=93f970ce7b086a31eb6e8faf1e17a5b2982c922f
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Apr 22 11:25:54 2010 +0100
wineps.drv: Calculate the font size directly from the logfont.
---
dlls/wineps.drv/download.c | 45 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c
index a6ab9d0..5a873e1 100644
--- a/dlls/wineps.drv/download.c
+++ b/dlls/wineps.drv/download.c
@@ -202,6 +202,37 @@ BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev)
return TRUE;
}
+static UINT calc_ppem_for_height(HDC hdc, LONG height)
+{
+ BYTE os2[78]; /* size of version 0 table */
+ BYTE hhea[8]; /* just enough to get the ascender and descender */
+ LONG ascent = 0, descent = 0;
+ UINT emsize;
+
+ if(height < 0) return -height;
+
+ if(GetFontData(hdc, MS_MAKE_TAG('O','S','/','2'), 0, os2, sizeof(os2)) == sizeof(os2))
+ {
+ ascent = GET_BE_WORD(os2 + 74); /* usWinAscent */
+ descent = GET_BE_WORD(os2 + 76); /* usWinDescent */
+ }
+
+ if(ascent + descent == 0)
+ {
+ if(GetFontData(hdc, MS_MAKE_TAG('h','h','e','a'), 0, hhea, sizeof(hhea)) == sizeof(hhea))
+ {
+ ascent = (signed short)GET_BE_WORD(hhea + 4); /* Ascender */
+ descent = -(signed short)GET_BE_WORD(hhea + 6); /* Descender */
+ }
+ }
+
+ if(ascent + descent == 0) return height;
+
+ get_bbox(hdc, NULL, &emsize);
+
+ return MulDiv(emsize, height, ascent + descent);
+}
+
/****************************************************************************
* PSDRV_WriteSetDownloadFont
*
@@ -214,6 +245,8 @@ BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev)
LPOUTLINETEXTMETRICA potm;
DWORD len = GetOutlineTextMetricsA(physDev->hdc, 0, NULL);
DOWNLOAD *pdl;
+ LOGFONTW lf;
+ UINT ppem;
assert(physDev->font.fontloc == Download);
@@ -223,16 +256,18 @@ BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev)
get_download_name(physDev, potm, &ps_name);
physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name);
- physDev->font.size = abs(PSDRV_YWStoDS(physDev, /* ppem */
- potm->otmTextMetrics.tmAscent +
- potm->otmTextMetrics.tmDescent -
- potm->otmTextMetrics.tmInternalLeading));
+ if (!GetObjectW( GetCurrentObject(physDev->hdc, OBJ_FONT), sizeof(lf), &lf ))
+ return FALSE;
+
+ ppem = calc_ppem_for_height(physDev->hdc, lf.lfHeight);
+
+ physDev->font.size = abs(PSDRV_YWStoDS(physDev, ppem));
+
physDev->font.underlineThickness = potm->otmsUnderscoreSize;
physDev->font.underlinePosition = potm->otmsUnderscorePosition;
physDev->font.strikeoutThickness = potm->otmsStrikeoutSize;
physDev->font.strikeoutPosition = potm->otmsStrikeoutPosition;
-
if(physDev->font.fontinfo.Download == NULL) {
RECT bbox;
UINT emsize;
More information about the wine-cvs
mailing list