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/memgfx.c src/lib/memgfx.c index e1d5bb4..a921d44 100644 --- src/lib/memgfx.c +++ src/lib/memgfx.c @@ -739,30 +739,44 @@ void mgText(struct memGfx *mg, int x, int y, Color color, MgFont *font, char *text) /* Draw a line of text with upper left corner x,y. */ { switch (mg->fontMethod) { case FONT_METHOD_GEM: gfText(mg, font, text, x, y, color, mgTextBlit, MG_WHITE); break; case FONT_METHOD_FREETYPE: ftText(mg, x, y, color, font, text); break; } } +void mgTextInBox(struct memGfx *mg, int x, int y, int width, int height, + Color color, MgFont *font, char *text) +/* Draw a line of text centered in box defined by x/y/width/height */ +{ +#ifndef USE_FREETYPE +// should draw an X +#else +if (face == NULL) // have we turned on freetype + ;// should draw an X +else + ftTextInBox(mg, x, y, width, height, color, font, text); +#endif +} + void mgTextCentered(struct memGfx *mg, int x, int y, int width, int height, Color color, MgFont *font, char *text) /* Draw a line of text centered in box defined by x/y/width/height */ { int fWidth, fHeight; int xoff, yoff; fWidth = mgFontStringWidth(font, text); fHeight = mgFontPixelHeight(font); xoff = x + (width - fWidth)/2; yoff = y + (height - fHeight)/2; if (font == mgSmallFont()) { xoff += 1; yoff += 1; } @@ -999,30 +1013,31 @@ return ""; } void vgMgMethods(struct vGfx *vg) /* Fill in virtual graphics methods for memory based drawing. */ { vg->pixelBased = TRUE; vg->close = (vg_close)mgFree; vg->dot = (vg_dot)mgSlowDot; vg->getDot = (vg_getDot)mgSlowGetDot; vg->box = (vg_box)mgDrawBox; vg->line = (vg_line)mgDrawLine; vg->text = (vg_text)mgText; vg->textRight = (vg_textRight)mgTextRight; vg->textCentered = (vg_textCentered)mgTextCentered; +vg->textInBox = (vg_textInBox)mgTextInBox; vg->findColorIx = (vg_findColorIx)mgFindColor; vg->colorIxToRgb = (vg_colorIxToRgb)mgColorIxToRgb; vg->setWriteMode = (vg_setWriteMode)mgSetWriteMode; vg->setClip = (vg_setClip)mgSetClip; vg->unclip = (vg_unclip)mgUnclip; vg->verticalSmear = (vg_verticalSmear)mgVerticalSmear; vg->fillUnder = (vg_fillUnder)mgFillUnder; vg->drawPoly = (vg_drawPoly)mgDrawPoly; vg->circle = (vg_circle)mgCircle; vg->ellipse = (vg_ellipse)mgEllipse; vg->curve = (vg_curve)mgCurve; vg->setHint = (vg_setHint)mgSetHint; vg->getHint = (vg_getHint)mgGetHint; vg->getFontPixelHeight = (vg_getFontPixelHeight)mgGetFontPixelHeight; vg->getFontStringWidth = (vg_getFontStringWidth)mgGetFontStringWidth;