5c16e9df442a6a66c91f8cbf52f7543cb9cb4517 braney Mon Dec 6 16:34:22 2021 -0800 add new function to the graphics library to put text in a box that is used by the logo function of wiggle draws diff --git src/lib/psGfx.c src/lib/psGfx.c index d613a95..8492bab 100644 --- src/lib/psGfx.c +++ src/lib/psGfx.c @@ -269,30 +269,62 @@ fprintf(ps->f, ") show\n"); } void psTextRight(struct psGfx *ps, double x, double y, double width, double height, char *text) /* Draw a line of text right justified in box defined by x/y/width/height */ { y += (height - ps->fontHeight)/2; psMoveTo(ps, x+width, y + ps->fontHeight); fprintf(ps->f, "("); psTextOutEscaped(ps, text); fprintf(ps->f, ") showBefore\n"); } +void psTextInBox(struct psGfx *ps, double x, double y, + double width, double height, + char *text) +/* Draw a line of text that fills a box. */ +{ +if (height == 0) + return; +if (height > 0) + { + psMoveTo(ps, x, y + height); + fprintf(ps->f, "gsave\n"); + psSetFont(ps, "Courier", 1.0); + fprintf(ps->f, "%g %g scale\n", width,height); + fprintf(ps->f, "("); + psTextOutEscaped(ps, text); + fprintf(ps->f, ") show\n"); + fprintf(ps->f, "grestore\n"); + } +else + { + //height = -height; + psMoveTo(ps, x, y); + fprintf(ps->f, "gsave\n"); + psSetFont(ps, "Courier", 1.0); + fprintf(ps->f, "%g %g scale\n", width,height); + fprintf(ps->f, "("); + psTextOutEscaped(ps, text); + fprintf(ps->f, ") show\n"); + fprintf(ps->f, "grestore\n"); + } +} + void psTextCentered(struct psGfx *ps, double x, double y, double width, double height, char *text) /* Draw a line of text centered in box defined by x/y/width/height */ { y += (height - ps->fontHeight)/2; psMoveTo(ps, x+width/2, y + ps->fontHeight); fprintf(ps->f, "("); psTextOutEscaped(ps, text); fprintf(ps->f, ") showMiddle\n"); } void psTextDown(struct psGfx *ps, double x, double y, char *text) /* Output text going downwards rather than across at position. */ {