Commit 8ce10f14 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

wineps.drv: Add world transform support for fonts.

parent 5075f00f
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment