c73823892aa5384025c64a22b5da8e4332d38efd braney Wed Sep 30 14:53:48 2020 -0700 get the postscript driver to allow font specification. Use the correct names for fonts. diff --git src/lib/pscmGfx.c src/lib/pscmGfx.c index 6c859a7..06db3d6 100644 --- src/lib/pscmGfx.c +++ src/lib/pscmGfx.c @@ -235,31 +235,31 @@ { pscmSetColor(pscm, c); psDrawBox(ps, x, yOff, 1, height); } } } static void pscmSetFont(struct pscmGfx *pscm, MgFont *font) /* Set font. */ { /* For now we basically still get the sizing info from the old * gem fonts. I'm not sure how to get sizing info out of * PostScript. We'll try and arrange it so that the PostScript * fonts match the gem fonts more or less. */ void *v = font; -if (v != pscm->curFont) +if ((pscm->fontMethod == 0) && (v != pscm->curFont)) { psTimesFont(pscm->ps, font->psHeight); pscm->curFont = v; } } void pscmText(struct pscmGfx *pscm, int x, int y, int color, MgFont *font, char *text) /* Draw a line of text with upper left corner x,y. */ { pscmSetColor(pscm, color); pscmSetFont(pscm, font); psTextAt(pscm->ps, x, y, text); boxPscm = NULL; } @@ -740,45 +740,54 @@ { pscmSetColor(pscm, color); if (isDashed) psSetDash(pscm->ps, TRUE); else psSetDash(pscm->ps, FALSE); // PostScript bezier is cubic -- derive the two control points from the single quadratic control point double c1x = bezierQuadraticToCubic(x1, x2); double c1y = bezierQuadraticToCubic(y1, y2); double c2x = bezierQuadraticToCubic(x3, x2); double c2y = bezierQuadraticToCubic(y3, y2); psDrawCurve(pscm->ps, (double)x1, (double)y1, c1x, c1y, c2x, c2y, (double)x3, (double)y3); psSetDash(pscm->ps, FALSE); } +void pscmSetFontMethod(struct pscmGfx *pscm, unsigned int method, char *fontName, char *fontFile) +/* Which font drawing method shoud we use. */ +{ +pscm->fontMethod = method; +pscm->fontName = cloneString(fontName); +psSetFont(pscm->ps, fontName); +} + struct vGfx *vgOpenPostScript(int width, int height, char *fileName) /* Open up something that will someday be a PostScript file. */ { struct vGfx *vg = vgHalfInit(width, height); vg->data = pscmOpen(width, height, fileName); vg->close = (vg_close)pscmClose; vg->dot = (vg_dot)pscmDot; vg->box = (vg_box)pscmBox; vg->line = (vg_line)pscmLine; vg->text = (vg_text)pscmText; vg->textRight = (vg_textRight)pscmTextRight; vg->textCentered = (vg_textCentered)pscmTextCentered; vg->findColorIx = (vg_findColorIx)pscmFindColorIx; vg->colorIxToRgb = (vg_colorIxToRgb)pscmColorIxToRgb; vg->setClip = (vg_setClip)pscmSetClip; vg->unclip = (vg_unclip)pscmUnclip; vg->verticalSmear = (vg_verticalSmear)pscmVerticalSmear; vg->fillUnder = (vg_fillUnder)pscmFillUnder; vg->drawPoly = (vg_drawPoly)pscmDrawPoly; vg->ellipse = (vg_ellipse)pscmEllipse; vg->circle = (vg_circle)pscmCircle; vg->curve = (vg_curve)pscmCurve; vg->setHint = (vg_setHint)pscmSetHint; vg->getHint = (vg_getHint)pscmGetHint; vg->getFontPixelHeight = (vg_getFontPixelHeight)pscmGetFontPixelHeight; vg->getFontStringWidth = (vg_getFontStringWidth)pscmGetFontStringWidth; vg->setWriteMode = (vg_setWriteMode)pscmSetWriteMode; +vg->setFontMethod = (vg_setFontMethod)pscmSetFontMethod; return vg; }