Module: wine Branch: master Commit: 8ce10f14268e936c38eb6b2db26a7c60240b48a1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=8ce10f14268e936c38eb6b2db2...
Author: Huw Davies huw@codeweavers.com Date: Fri Apr 23 13:15:05 2010 +0100
wineps.drv: Add world transform support for fonts.
---
dlls/wineps.drv/builtin.c | 6 ++++-- dlls/wineps.drv/download.c | 21 ++++++++++++++++++++- dlls/wineps.drv/ps.c | 8 ++++---- dlls/wineps.drv/psdrv.h | 9 +++++++-- 4 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index e0a3951..b57cfb2 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -79,7 +79,9 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, (float)(wm->usWinAscent + wm->usWinDescent); }
- font->size = (INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + font->size.xx = (INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm); + font->size.xy = font->size.yx = 0; + font->size.yy = -(INT)Round(font->fontinfo.Builtin.scale * (float)wm->usUnitsPerEm);
usUnitsPerEm = (USHORT)Round((float)(wm->usUnitsPerEm) * font->fontinfo.Builtin.scale); sAscender = (SHORT)Round((float)(wm->sAscender) * font->fontinfo.Builtin.scale); @@ -140,7 +142,7 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font, font->strikeoutThickness = font->underlineThickness;
TRACE("Selected PS font '%s' size %d weight %d.\n", afm->FontName, - font->size, tm->tmWeight ); + font->size.xx, tm->tmWeight ); TRACE("H = %d As = %d Des = %d IL = %d EL = %d\n", tm->tmHeight, tm->tmAscent, tm->tmDescent, tm->tmInternalLeading, tm->tmExternalLeading); diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c index 5a873e1..8be03c9 100644 --- a/dlls/wineps.drv/download.c +++ b/dlls/wineps.drv/download.c @@ -33,6 +33,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
+BOOL WINAPI GetTransform( HDC hdc, DWORD which, XFORM *xform ); + #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ ( ( (DWORD)_x4 << 24 ) | \ ( (DWORD)_x3 << 16 ) | \ @@ -233,6 +235,10 @@ static UINT calc_ppem_for_height(HDC hdc, LONG height) return MulDiv(emsize, height, ascent + descent); }
+static inline float ps_round(float f) +{ + return (f > 0) ? (f + 0.5) : (f - 0.5); +} /**************************************************************************** * PSDRV_WriteSetDownloadFont * @@ -247,6 +253,7 @@ BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev) DOWNLOAD *pdl; LOGFONTW lf; UINT ppem; + XFORM xform;
assert(physDev->font.fontloc == Download);
@@ -261,7 +268,19 @@ BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev)
ppem = calc_ppem_for_height(physDev->hdc, lf.lfHeight);
- physDev->font.size = abs(PSDRV_YWStoDS(physDev, ppem)); + /* Retrieve the world -> device transform */ + GetTransform(physDev->hdc, 0x204, &xform); + + physDev->font.size.xx = ps_round(ppem * xform.eM11); + physDev->font.size.xy = ps_round(ppem * xform.eM12); + physDev->font.size.yx = ps_round(ppem * xform.eM21); + physDev->font.size.yy = ps_round(ppem * xform.eM22); + + if(GetMapMode(physDev->hdc) == MM_TEXT) + { + physDev->font.size.yx *= -1; + physDev->font.size.yy *= -1; + }
physDev->font.underlineThickness = potm->otmsUnderscoreSize; physDev->font.underlinePosition = potm->otmsUnderscorePosition; diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 89728fd..e06e892 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -115,9 +115,9 @@ static const char psrectangle[] = /* x, y, width, height, -width */ static const char psglyphshow[] = /* glyph name */ "/%s glyphshow\n";
-static const char pssetfont[] = /* fontname, xscale, yscale, ascent, escapement */ +static const char pssetfont[] = /* fontname, xx_scale, xy_scale, yx_scale, yy_scale, escapement */ "/%s findfont\n" -"[%d 0 0 %d 0 0]\n" +"[%d %d %d %d 0 0]\n" "%d 10 div matrix rotate\n" "matrix concatmatrix\n" "makefont setfont\n"; @@ -501,7 +501,7 @@ BOOL PSDRV_WriteArc(PSDRV_PDEVICE *physDev, INT x, INT y, INT w, INT h, double a }
-BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, INT size, INT escapement) +BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, matrix size, INT escapement) { char *buf;
@@ -513,7 +513,7 @@ BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, INT size, INT return FALSE; }
- sprintf(buf, pssetfont, name, size, -size, -escapement); + sprintf(buf, pssetfont, name, size.xx, size.xy, size.yx, size.yy, -escapement);
PSDRV_WriteSpool(physDev, buf, strlen(buf)); HeapFree(PSDRV_Heap, 0, buf); diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 9b2ec50..854cdd2 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -298,6 +298,11 @@ enum fontloc { Builtin, Download };
+typedef struct +{ + INT xx, xy, yx, yy; +} matrix; + typedef struct { enum fontloc fontloc; union { @@ -305,7 +310,7 @@ typedef struct { DOWNLOAD *Download; } fontinfo;
- int size; + matrix size; PSCOLOR color; BOOL set; /* Have we done a setfont yet */
@@ -436,7 +441,7 @@ extern BOOL PSDRV_WriteRectangle(PSDRV_PDEVICE *physDev, INT x, INT y, INT width INT height); extern BOOL PSDRV_WriteRRectangle(PSDRV_PDEVICE *physDev, INT x, INT y, INT width, INT height); -extern BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, INT size, +extern BOOL PSDRV_WriteSetFont(PSDRV_PDEVICE *physDev, const char *name, matrix size, INT escapement); extern BOOL PSDRV_WriteGlyphShow(PSDRV_PDEVICE *physDev, LPCSTR g_name); extern BOOL PSDRV_WriteSetPen(PSDRV_PDEVICE *physDev);