Huw Davies : wineps: Add support for printing fake italic fonts.

Alexandre Julliard julliard at winehq.org
Mon Jul 2 13:22:01 CDT 2012


Module: wine
Branch: master
Commit: bb1740a42e0a4b0522bc32f65a017934788931df
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bb1740a42e0a4b0522bc32f65a017934788931df

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Jul  2 13:42:16 2012 +0100

wineps: Add support for printing fake italic fonts.

---

 dlls/wineps.drv/builtin.c  |    2 +-
 dlls/wineps.drv/download.c |   21 ++++++++++++++++++++-
 dlls/wineps.drv/ps.c       |   44 +++++++++++++++++++++++++++++++++++---------
 dlls/wineps.drv/psdrv.h    |    3 ++-
 4 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c
index 7fc23cf..873a473 100644
--- a/dlls/wineps.drv/builtin.c
+++ b/dlls/wineps.drv/builtin.c
@@ -238,7 +238,7 @@ BOOL PSDRV_WriteSetBuiltinFont(PHYSDEV dev)
     PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
 
     return PSDRV_WriteSetFont(dev, physDev->font.fontinfo.Builtin.afm->FontName,
-			      physDev->font.size, physDev->font.escapement);
+                              physDev->font.size, physDev->font.escapement, FALSE);
 }
 
 BOOL PSDRV_WriteBuiltinGlyphShow(PHYSDEV dev, LPCWSTR str, INT count)
diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c
index 6af4841..6b87172 100644
--- a/dlls/wineps.drv/download.c
+++ b/dlls/wineps.drv/download.c
@@ -239,6 +239,24 @@ static inline float ps_round(float f)
 {
     return (f > 0) ? (f + 0.5) : (f - 0.5);
 }
+
+static BOOL is_fake_italic( HDC hdc )
+{
+    TEXTMETRICW tm;
+    BYTE head[54]; /* the head table is 54 bytes long */
+    WORD mac_style;
+
+    GetTextMetricsW( hdc, &tm );
+    if (!tm.tmItalic) return FALSE;
+
+    if (GetFontData( hdc, MS_MAKE_TAG('h','e','a','d'), 0, head, sizeof(head) ) == GDI_ERROR)
+        return FALSE;
+
+    mac_style = GET_BE_WORD( head + 44 );
+    TRACE( "mac style %04x\n", mac_style );
+    return !(mac_style & 2);
+}
+
 /****************************************************************************
  *  PSDRV_WriteSetDownloadFont
  *
@@ -328,7 +346,8 @@ BOOL PSDRV_WriteSetDownloadFont(PHYSDEV dev)
     }
 
 
-    PSDRV_WriteSetFont(dev, ps_name, physDev->font.size, physDev->font.escapement);
+    PSDRV_WriteSetFont(dev, ps_name, physDev->font.size, physDev->font.escapement,
+                       is_fake_italic( dev->hdc ));
 
     HeapFree(GetProcessHeap(), 0, ps_name);
     HeapFree(GetProcessHeap(), 0, potm);
diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c
index 2e7597a..b6bbe7a 100644
--- a/dlls/wineps.drv/ps.c
+++ b/dlls/wineps.drv/ps.c
@@ -129,11 +129,23 @@ static const char psrectangle[] = /* x, y, width, height, -width */
 static const char psglyphshow[] = /* glyph name */
 "/%s glyphshow\n";
 
-static const char pssetfont[] = /* fontname, xx_scale, xy_scale, yx_scale, yy_scale, escapement */
-"/%s findfont\n"
-"[%d %d %d %d 0 0]\n"
+static const char psfindfont[] = /* fontname */
+"/%s findfont\n";
+
+static const char psfakeitalic[] =
+"[1 0 0.25 1 0 0]\n";
+
+static const char pssizematrix[] =
+"[%d %d %d %d 0 0]\n";
+
+static const char psconcat[] =
+"matrix concatmatrix\n";
+
+static const char psrotatefont[] = /* escapement */
 "%d 10 div matrix rotate\n"
-"matrix concatmatrix\n"
+"matrix concatmatrix\n";
+
+static const char pssetfont[] =
 "makefont setfont\n";
 
 static const char pssetline[] = /* width, join, endcap */
@@ -554,22 +566,36 @@ BOOL PSDRV_WriteCurveTo(PHYSDEV dev, POINT pts[3])
     return PSDRV_WriteSpool(dev, buf, strlen(buf));
 }
 
-
-BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement)
+BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement, BOOL fake_italic)
 {
     char *buf;
 
-    buf = HeapAlloc( GetProcessHeap(), 0, sizeof(pssetfont) + strlen(name) + 40 );
+    buf = HeapAlloc( GetProcessHeap(), 0, strlen(name) + 256 );
 
     if(!buf) {
         WARN("HeapAlloc failed\n");
         return FALSE;
     }
 
-    sprintf(buf, pssetfont, name, size.xx, size.xy, size.yx, size.yy, -escapement);
+    sprintf( buf, psfindfont, name );
+    PSDRV_WriteSpool( dev, buf, strlen(buf) );
 
-    PSDRV_WriteSpool(dev, buf, strlen(buf));
+    if (fake_italic) PSDRV_WriteSpool( dev, psfakeitalic, sizeof(psfakeitalic) - 1 );
+
+    sprintf( buf, pssizematrix, size.xx, size.xy, size.yx, size.yy );
+    PSDRV_WriteSpool( dev, buf, strlen(buf) );
+
+    if (fake_italic) PSDRV_WriteSpool( dev, psconcat, sizeof(psconcat) - 1 );
+
+    if (escapement)
+    {
+        sprintf( buf, psrotatefont, -escapement );
+        PSDRV_WriteSpool( dev, buf, strlen(buf) );
+    }
+
+    PSDRV_WriteSpool( dev, pssetfont, sizeof(pssetfont) - 1 );
     HeapFree( GetProcessHeap(), 0, buf );
+
     return TRUE;
 }
 
diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h
index 42ace2d..52f84e7 100644
--- a/dlls/wineps.drv/psdrv.h
+++ b/dlls/wineps.drv/psdrv.h
@@ -489,7 +489,8 @@ extern BOOL PSDRV_WriteLineTo(PHYSDEV dev, INT x, INT y) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteStroke(PHYSDEV dev) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteRectangle(PHYSDEV dev, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteRRectangle(PHYSDEV dev, INT x, INT y, INT width, INT height) DECLSPEC_HIDDEN;
-extern BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement) DECLSPEC_HIDDEN;
+extern BOOL PSDRV_WriteSetFont(PHYSDEV dev, const char *name, matrix size, INT escapement,
+                               BOOL fake_italic) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteGlyphShow(PHYSDEV dev, LPCSTR g_name) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteSetPen(PHYSDEV dev) DECLSPEC_HIDDEN;
 extern BOOL PSDRV_WriteArc(PHYSDEV dev, INT x, INT y, INT w, INT h,




More information about the wine-cvs mailing list