diff --git a/graphics/psdrv/ps.c b/graphics/psdrv/ps.c index 438e21a8824..04e23aaa504 100644 --- a/graphics/psdrv/ps.c +++ b/graphics/psdrv/ps.c @@ -104,6 +104,13 @@ static char psrectangle[] = /* x, y, width, height, -width */ "%d 0 rlineto\n" "closepath\n"; +static char psrrectangle[] = /* x, y, width, height, -width */ +"%d %d rmoveto\n" +"%d 0 rlineto\n" +"0 %d rlineto\n" +"%d 0 rlineto\n" +"closepath\n"; + static char psshow[] = /* string */ "(%s) show\n"; @@ -482,6 +489,15 @@ BOOL PSDRV_WriteRectangle(DC *dc, INT x, INT y, INT width, return PSDRV_WriteSpool(dc, buf, strlen(buf)); } +BOOL PSDRV_WriteRRectangle(DC *dc, INT x, INT y, INT width, + INT height) +{ + char buf[100]; + + sprintf(buf, psrrectangle, x, y, width, height, -width); + return PSDRV_WriteSpool(dc, buf, strlen(buf)); +} + BOOL PSDRV_WriteArc(DC *dc, INT x, INT y, INT w, INT h, double ang1, double ang2) { diff --git a/graphics/psdrv/text.c b/graphics/psdrv/text.c index 411930eaa73..1dfba92b923 100644 --- a/graphics/psdrv/text.c +++ b/graphics/psdrv/text.c @@ -81,6 +81,76 @@ BOOL PSDRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags, PSDRV_WriteMoveTo(dc, x, y); PSDRV_WriteShow(dc, strbuf, strlen(strbuf)); + /* + * Underline and strikeout attributes. + */ + if ((physDev->font.tm.tmUnderlined) || (physDev->font.tm.tmStruckOut)) { + + /* Get the thickness and the position for the underline attribute */ + /* We'll use the same thickness for the strikeout attribute */ + + float thick = physDev->font.afm->UnderlineThickness * physDev->font.scale; + float pos = -physDev->font.afm->UnderlinePosition * physDev->font.scale; + SIZE size; + INT escapement = physDev->font.escapement; + + TRACE(psdrv, "Position = %f Thickness %f Escapement %d\n", + pos, thick, escapement); + + /* Get the width of the text */ + + PSDRV_GetTextExtentPoint(dc, strbuf, strlen(strbuf), &size); + size.cx = XLSTODS(dc, size.cx); + + /* Do the underline */ + + if (physDev->font.tm.tmUnderlined) { + if (escapement != 0) /* rotated text */ + { + PSDRV_WriteGSave(dc); /* save the graphics state */ + PSDRV_WriteMoveTo(dc, x, y); /* move to the start */ + + /* temporarily rotate the coord system */ + PSDRV_WriteRotate(dc, -escapement/10); + + /* draw the underline relative to the starting point */ + PSDRV_WriteRRectangle(dc, 0, (INT)pos, size.cx, (INT)thick); + } + else + PSDRV_WriteRectangle(dc, x, y + (INT)pos, size.cx, (INT)thick); + + PSDRV_WriteFill(dc); + + if (escapement != 0) /* rotated text */ + PSDRV_WriteGRestore(dc); /* restore the graphics state */ + } + + /* Do the strikeout */ + + if (physDev->font.tm.tmStruckOut) { + pos = -physDev->font.tm.tmAscent / 2; + + if (escapement != 0) /* rotated text */ + { + PSDRV_WriteGSave(dc); /* save the graphics state */ + PSDRV_WriteMoveTo(dc, x, y); /* move to the start */ + + /* temporarily rotate the coord system */ + PSDRV_WriteRotate(dc, -escapement/10); + + /* draw the underline relative to the starting point */ + PSDRV_WriteRRectangle(dc, 0, (INT)pos, size.cx, (INT)thick); + } + else + PSDRV_WriteRectangle(dc, x, y + (INT)pos, size.cx, (INT)thick); + + PSDRV_WriteFill(dc); + + if (escapement != 0) /* rotated text */ + PSDRV_WriteGRestore(dc); /* restore the graphics state */ + } + } + HeapFree(PSDRV_Heap, 0, strbuf); return TRUE; } diff --git a/include/psdrv.h b/include/psdrv.h index e695702b2f9..bb06e67b672 100644 --- a/include/psdrv.h +++ b/include/psdrv.h @@ -272,6 +272,8 @@ extern BOOL PSDRV_WriteLineTo(DC *dc, INT x, INT y); extern BOOL PSDRV_WriteStroke(DC *dc); extern BOOL PSDRV_WriteRectangle(DC *dc, INT x, INT y, INT width, INT height); +extern BOOL PSDRV_WriteRRectangle(DC *dc, INT x, INT y, INT width, + INT height); extern BOOL PSDRV_WriteSetFont(DC *dc, BOOL UseANSI); extern BOOL PSDRV_WriteShow(DC *dc, char *str, INT count); extern BOOL PSDRV_WriteReencodeFont(DC *dc);