diff -Naur yorick/gist/gist.c yorick-build/gist/gist.c --- yorick/gist/gist.c 2020-11-17 21:47:00.454732007 +1100 +++ yorick-build/gist/gist.c 2020-11-17 21:47:00.541400404 +1100 @@ -37,7 +37,7 @@ { FG_COLOR, M_ASTERISK, 1.0 }, /* marker attributes */ { FG_COLOR, F_SOLID }, /* fill attributes */ { FG_COLOR, 0, 0.0156, - TX_RIGHT, TH_NORMAL, TV_NORMAL, 0 }, /* text attributes */ + TX_RIGHT, TH_NORMAL, TV_NORMAL, 0, 0 }, /* text attributes */ { 0, 0, 0, 0.16, 0.14, 0, 0.13, 0.11375, 1.0, 1.0 }, /* decorated line attributes */ { 0, 0.125 }, /* vector attributes */ @@ -329,6 +329,7 @@ /* Swap in text attributes appropriate for markers */ gistA.t.color= gistA.m.color; gistA.t.font= MARKER_FONT; + strcpy(gistA.t.xftfont,""); gistA.t.height= gistA.m.size * DEFAULT_MARKER_SIZE; gistA.t.orient= TX_RIGHT; gistA.t.alignH= TH_CENTER; diff -Naur yorick/gist/gist.h yorick-build/gist/gist.h --- yorick/gist/gist.h 2020-11-17 21:47:00.454732007 +1100 +++ yorick-build/gist/gist.h 2020-11-17 21:47:00.541400404 +1100 @@ -259,7 +259,8 @@ /* GKS is missing a text opacity flag. */ int opaque; - + char xftfont[256]; /* xft text font name */ + /* A font is a type face optionally ORed with T_BOLD and/or T_ITALIC. */ /* Available point sizes (for X) are 8, 10, 12, 14, 18, and 24 */ #define T_BOLD 1 diff -Naur yorick/gist/hlevel.c yorick-build/gist/hlevel.c --- yorick/gist/hlevel.c 2020-11-17 21:47:00.454732007 +1100 +++ yorick-build/gist/hlevel.c 2020-11-17 21:47:00.541400404 +1100 @@ -285,7 +285,7 @@ static GpMarkerAttribs mDefault= { FG_COLOR, 0, 1.0 }; static GpFillAttribs fDefault= { FG_COLOR, F_SOLID }; static GpTextAttribs tDefault= { FG_COLOR, 0, 0.0156, - TX_RIGHT, TH_NORMAL, TV_NORMAL }; + TX_RIGHT, TH_NORMAL, TV_NORMAL, 0 }; static GaLineAttribs dlDefault= { 0, 0, 0, 0.16, 0.14, 0, 0.13, 0.11375, 1.0, 1.0 }; static GaVectAttribs vectDefault= { 0, 0.125 }; diff -Naur yorick/gist/xbasic.c yorick-build/gist/xbasic.c --- yorick/gist/xbasic.c 2020-11-17 21:47:00.458065407 +1100 +++ yorick-build/gist/xbasic.c 2020-11-17 21:47:00.541400404 +1100 @@ -191,7 +191,8 @@ /* call p_font before any calls to TextWidth * - may improve efficiency of p_txwidth, p_txheight */ - p_font(current_win, gistA.t.font, current_fsize, gistA.t.orient); + p_font(current_win, gistA.t.font, current_fsize, + gistA.t.orient, gistA.t.xftfont); /* Set nLines, maxWidth, nChars, prevWidth */ firstTextLine = 1; @@ -279,8 +280,8 @@ *ix= dx + ix0; *iy= dy + iy0; - if (nChunk) p_font(current_win, - gistA.t.font, current_fsize, gistA.t.orient); + if (nChunk) p_font(current_win, gistA.t.font, current_fsize, + gistA.t.orient, gistA.t.xftfont); return nChunk; } @@ -332,7 +333,8 @@ if (current_state&1) yadj+= dy_super; else if (current_state&2) yadj-= dy_sub; if (nChunk && (current_state&4)) - p_font(current_win, gistA.t.font, current_fsize, gistA.t.orient); + p_font(current_win, gistA.t.font, current_fsize, + gistA.t.orient, gistA.t.xftfont); current_state= 0; } else { @@ -358,11 +360,13 @@ c= txt[nChunk]; if ((nChunk+10) { if (len==1 && (current_state&4) && text[0]==']') txt = caret; else txt = text; - p_text(w, ix, iy, txt, len); + p_text(w, ix, iy, txt, len, gistA.t.opaque); } len = GxJustifyNext(&text, &ix, &iy); } while (len>=0); diff -Naur yorick/gist/xfancy.c yorick-build/gist/xfancy.c --- yorick/gist/xfancy.c 2020-11-17 21:47:00.458065407 +1100 +++ yorick-build/gist/xfancy.c 2020-11-17 21:47:00.541400404 +1100 @@ -328,8 +328,8 @@ p_rect(w, 0, 0, fxe->widthButton, fxe->xe.topMargin-1, 0); if (fxe->buttonState) HighlightButton(fxe); else p_color(w, fg); - p_font(w, P_GUI_FONT, 15, 0); - p_text(w, 3, fxe->baseline, "System", 6); + p_font(w, P_GUI_FONT, 15, 0, ""); + p_text(w, 3, fxe->baseline, "System", 6, 0); } } @@ -431,8 +431,8 @@ p_color(w, P_BG); p_rect(w, fxe->widthButton+1, 0, fxe->xe.wtop, fxe->xe.topMargin-2, 0); p_color(w, P_FG); - p_font(w, P_GUI_FONT, 15, 0); - p_text(w, fxe->widthButton+4, fxe->baseline, msg, len); + p_font(w, P_GUI_FONT, 15, 0, ""); + p_text(w, fxe->widthButton+4, fxe->baseline, msg, len, 0); } } diff -Naur yorick/i/style.i yorick-build/i/style.i --- yorick/i/style.i 2020-11-17 21:47:00.464732207 +1100 +++ yorick-build/i/style.i 2020-11-17 21:47:00.541400404 +1100 @@ -665,6 +665,7 @@ alignV: 0=normal 1=top 2=cap 3=half 4=base 5=bot */ int opaque; + char xftfont(256); } struct GaAxisStyle { diff -Naur yorick/i0/graph.i yorick-build/i0/graph.i --- yorick/i0/graph.i 2020-11-17 21:47:00.468065607 +1100 +++ yorick-build/i0/graph.i 2020-11-17 21:47:00.541400404 +1100 @@ -782,6 +782,26 @@ value can be <0 if the information is unavailable for some reason. SEE ALSO: window, limits, plg */ + +extern xft; +/* DOCUMENT xft() + or xft, 0/1 + As a function, returns: + -1: yorick was not build with xft support + 0: xft disabled + 1: xft enabled + + As a subroutine, allow to enable/disable the use of xft. + + If you have built yorick with Xft support, the fonts will be + rendered antialiased. Use the regular font keyword (see font), + with the Xft font syntax (e.g. "Times-14:slant"). There is + partial support for plotting the text at an arbitrary angle (use + negative values of orient). When xft is enabled, all text is + antialiased. + + SEE ALSO: font, orient + */ /*= SECTION(plotter) plotting functions ====================================*/ @@ -1455,6 +1475,20 @@ The font keyword may also be an integer: 0 is Courier, 4 is Times, 8 is Helvetica, 12 is Symbol, 16 is New Century Schoolbook, and you add 1 to get boldface and/or 2 to get italic (or oblique). + + If you have built yorick with Xft support, the fonts will be + rendered antialiased. You can use the regular font keyword as + above (which will render the font antialiased), or use the newer + xft syntax for fonts: "-:=...", as in + "Sans-14", "Times-14:slant=1". The syntax even accepts alternate + fonts: "times,charter-12:bold" (times prefered, charter accepted, + 12 points, bold face). For more information, look at + http://keithp.com/~keithp/render/Xft.tutorial. You can set the + default font for plot titles and axis captions with + pltitle_xftfont. Note that if you want to use one of the regular + yorick fonts (see above) with the xft format, you will have to + capitalize it (e.g. "times:slant=1" will generate an error while + "Times:slant=1" will be correctly translated). The height is the font size in points; 14.0 is the default. X windows only has 8, 10, 12, 14, 18, and 24 point fonts, so @@ -1463,10 +1497,11 @@ By default, opaque=0 and text is transparent. Set opaque=1 to white-out a box before drawing the text. The default orient - (orient=0) is left-to-right text; set orient=1 for text rotated 90 - degrees so it reads upward, orient=2 for 180 degree rotation so - it is upside down, and orient=3 for 270 degree rotation so it - reads downward. + (orient=0) is left-to-right text; set orient=1 for text rotated + 90 degrees so it reads upward, orient=2 for 180 degree rotation + so it is upside down, and orient=3 for 270 degree rotation so it + reads downward. With Xft enabled, there is partial support for + arbitrary plotting angle (use negative integer values of orient). The default text justification, justify="NN" is normal is both the horizontal and vertical directions. Other possibilities diff -Naur yorick/opengl/test3d.c yorick-build/opengl/test3d.c --- yorick/opengl/test3d.c 2020-11-17 21:47:00.471399006 +1100 +++ yorick-build/opengl/test3d.c 2020-11-17 21:47:00.541400404 +1100 @@ -221,7 +221,7 @@ p_pen(w, 1, P_SOLID); seg_draw(w, 0,29, 300,29); p_font(w, P_COURIER | P_BOLD, 14, 0); - p_text(w, 20,20, "2D plotting area above line", 27); + p_text(w, 20,20, "2D plotting area above line", 27, 0); } else if (gl==glw1) { p_glcurrent(gl); check_err("on_expose entry"); /* may get error before p_glcurrent */ diff -Naur yorick/play/play.h yorick-build/play/play.h --- yorick/play/play.h 2020-11-17 21:47:00.474732406 +1100 +++ yorick-build/play/play.h 2020-11-17 21:47:00.544733804 +1100 @@ -164,7 +164,7 @@ /* screen graphics property setting functions */ PLUG_API void p_color(p_win *w, p_col_t color); -PLUG_API void p_font(p_win *w, int font, int pixsize, int orient); +PLUG_API void p_font(p_win *w, int font, int pixsize, int orient, char *xftfont); PLUG_API void p_pen(p_win *w, int width, int type); /* set point list for p_dots, p_lines, p_fill, p_segments (pairs in list) @@ -178,7 +178,7 @@ PLUG_API void p_d_map(p_win *w, double xt[], double yt[], int set); /* screen graphics drawing functions */ -PLUG_API void p_text(p_win *w, int x0, int y0, const char *text, int n); +PLUG_API void p_text(p_win *w, int x0, int y0, const char *text, int n, int opaque); PLUG_API void p_rect(p_win *w, int x0, int y0, int x1, int y1, int border); PLUG_API void p_ellipse(p_win *w, int x0, int y0, int x1, int y1, int border); PLUG_API void p_dots(p_win *w); diff -Naur yorick/play/README yorick-build/play/README --- yorick/play/README 2020-11-17 21:47:00.471399006 +1100 +++ yorick-build/play/README 2020-11-17 21:47:00.544733804 +1100 @@ -561,7 +561,7 @@ -------graphical output functions /* screen graphics drawing functions */ -extern void p_text(p_win *w, int x0, int y0, const char *text, int n); +extern void p_text(p_win *w, int x0, int y0, const char *text, int n, int opaque); draw first n characters of text at (x0,y0) in current font and color (x0,y0) is the point on the baseline at the beginning of the first character @@ -615,7 +615,7 @@ P_SOLID 0 P_DOT 2 P_DASHDOTDOT 4 P_DASH 1 P_DASHDOT 3 P_SQUARE 8 -extern void p_font(p_win *w, int font, int pixsize, int orient); +extern void p_font(p_win *w, int font, int pixsize, int orient, char *xftfont); set the current font this must be called not only when the font changes, but also after any graphics call to any other window has been made diff -Naur yorick/play/win/getdc.c yorick-build/play/win/getdc.c --- yorick/play/win/getdc.c 2020-11-17 21:47:00.474732406 +1100 +++ yorick-build/play/win/getdc.c 2020-11-17 21:47:00.544733804 +1100 @@ -19,7 +19,7 @@ static void w_font(p_scr *s, HDC dc, int font, int pixsize, int orient); void -p_font(p_win *w, int font, int pixsize, int orient) +p_font(p_win *w, int font, int pixsize, int orient, char *xftfont) { wp_font(w, font, pixsize, orient); } diff -Naur yorick/play/win/ptext.c yorick-build/play/win/ptext.c --- yorick/play/win/ptext.c 2020-11-17 21:47:00.474732406 +1100 +++ yorick-build/play/win/ptext.c 2020-11-17 21:47:00.544733804 +1100 @@ -12,7 +12,7 @@ #include "pstdlib.h" void -p_text(p_win *w, int x0, int y0, const char *text, int n) +p_text(p_win *w, int x0, int y0, const char *text, int n, int opaque) { HDC dc = w_getdc(w, 1); if (dc) { diff -Naur yorick/play/x11/connect.c yorick-build/play/x11/connect.c --- yorick/play/x11/connect.c 2020-11-17 21:47:00.478065806 +1100 +++ yorick-build/play/x11/connect.c 2020-11-17 21:47:00.544733804 +1100 @@ -22,7 +22,6 @@ int c, int dc); static void x_disconnect(x_display *xdpy); static int x_err_installed = 0; - x_display *x_displays = 0; p_scr * @@ -79,6 +78,15 @@ } x_parse_fonts(xdpy); /* see fonts.c */ +#ifdef HAVE_XFT + xdpy->use_xft = 0; + for (i=0 ; icached[i].f = 0; XFreeFont(dpy, font); } + +#ifdef HAVE_XFT + /* XftFontClose( dpy, xdpy->xftfont); */ + for (i=0 ; icursors[i]; xdpy->cursors[i] = None; diff -Naur yorick/play/x11/playwin.h yorick-build/play/x11/playwin.h --- yorick/play/x11/playwin.h 2020-11-17 21:47:00.478065806 +1100 +++ yorick-build/play/x11/playwin.h 2020-11-17 21:47:00.544733804 +1100 @@ -11,7 +11,20 @@ #include "play.h" #include "phash.h" #include - +#ifdef HAVE_XFT +#include +#define N_XFTFONT_CACHE 10 + +typedef struct xftcache xftcache; +struct xftcache { + XftFont *font; /* xftfont cache */ + Display *dpy; /* display these font are for */ + int pixsize; /* xft font pixsize cache */ + char name[256]; + int angle; /* xft font angle cache */ + int height; /* ascent + descent */ +}; +#endif #define N_FONT_CACHE 6 /* the Display struct may be shared among several root windows, @@ -36,6 +49,13 @@ XFontStruct *font; /* default font to use on this server */ int unload_font; /* non-0 if font must be unloaded */ +#ifdef HAVE_XFT + XftFont *xftfont; + int use_xft; + int xft_angle; + int xft_height; /* ascent + descent */ +#endif + struct { XFontStruct *f; int font, pixsize, next; diff -Naur yorick/play/x11/playx.h yorick-build/play/x11/playx.h --- yorick/play/x11/playx.h 2020-11-17 21:47:00.478065806 +1100 +++ yorick-build/play/x11/playx.h 2020-11-17 21:47:00.544733804 +1100 @@ -22,6 +22,7 @@ /* retrieve p_win* given Window id number, Display* (for event handling) * - the p_win context can be used to back up the hierarchy further * - this could be implemented using XContext mechanism */ +extern struct xftcache xftc[N_XFTFONT_CACHE]; extern x_display *x_dpy(Display *dpy); extern p_win *x_pwin(x_display *xdpy, Drawable d); diff -Naur yorick/play/x11/textout.c yorick-build/play/x11/textout.c --- yorick/play/x11/textout.c 2020-11-17 21:47:00.478065806 +1100 +++ yorick-build/play/x11/textout.c 2020-11-17 21:51:51.207283389 +1100 @@ -10,32 +10,102 @@ #include "config.h" #include "playx.h" - #include "pstdlib.h" - #include +#ifdef HAVE_XFT +#define PI 3.14159265358979323846 +#define XFT_DEBUG 0 +extern double cos(double); +extern double sin(double); +void p_xftfont(x_display *xdpy, int pixsize, int orient, char *xftfont); +void p_xfttext(p_win *w, int x0, int y0, const char *text, int n, int opaque); +char *p_font2xftfont(int font); +struct xftcache xftc[N_XFTFONT_CACHE]; +int xft_enabled=1; +#else +int xft_enabled=-1; +#endif + + int p_txheight(p_scr *s, int font, int pixsize, int *baseline) { +#ifdef HAVE_XFT + x_display *xdpy = s->xdpy; + + if (xft_enabled && xdpy->use_xft) { + /* Unfortunately, the baseline can only be computed accurately */ + /* with the unrotated font *and* the text. We don't have those 2 */ + /* available simultaneously, unless we also store the unrotated */ + /* xftfont, which I don't want to do. This is an approximation */ + if (baseline) *baseline = pixsize; + + /* If xft_angle is not 0 or 180, the ascent and descent reported */ + /* in xftfont structure are 0 (understandably). This is why it was */ + /* necessary to compute the height on the unrotated font in p_font */ + return xdpy->xft_height; + } +#endif XFontStruct *f = x_font(s->xdpy, font, pixsize); if (baseline) *baseline = f->ascent; return f->ascent + f->descent; /* hopefully close to pixsize */ + } int p_txwidth(p_scr *s, const char *text, int n, int font, int pixsize) { +#ifdef HAVE_XFT + x_display *xdpy = s->xdpy; + double ang = (double) xdpy->xft_angle; + + if (xft_enabled && xdpy->use_xft) { + XGlyphInfo extents; + Display *dpy = xdpy->dpy; + int len = strlen(text); + if (n<=0 || n>len) n = len; + XftTextExtents8( dpy, xdpy->xftfont, (XftChar8 *)text, n, &extents ); + + ang = ang * PI / 180.; + /* Unrotate the extents to deliver GxJustifyText what it expects */ + /* I could also run XftTextExtents8 on an unrotated xftfont, but */ + /* it would add an unnecessary overhead and storage */ + int xOffur; + xOffur = (int) (cos(ang) * extents.xOff - sin(ang) * extents.yOff); + return xOffur; + } +#endif + XFontStruct *f = x_font(s->xdpy, font, pixsize); int len = strlen(text); if (n<=0 || n>len) n = len; return XTextWidth(f, (char *)text, n); } + void -p_font(p_win *w, int font, int pixsize, int orient) +p_font(p_win *w, int font, int pixsize, int orient, char *xftfont) { p_scr *s = w->s; +#ifdef HAVE_XFT + x_display *xdpy = s->xdpy; + + if (xft_enabled) { + /* intercept request for xft font here */ + if (!xftfont || !strlen(xftfont)) { + if (XFT_DEBUG) printf("xftfont: finding local alternative to font#%d\n",font); + xftfont=p_font2xftfont(font); + if (XFT_DEBUG) printf("xftfont: found %s\n",xftfont); + } + if (xftfont && strlen(xftfont)) { + p_xftfont(xdpy, pixsize, orient, xftfont); + xdpy->use_xft = 1; + return; + } + } + xdpy->use_xft = 0; +#endif if (s->rotgc || s->tmp || s->image || s->pixmap!=None) x_rotzap(s); @@ -56,8 +126,112 @@ } } + +#ifdef HAVE_XFT void -p_text(p_win *w, int x0, int y0, const char *text, int n) +p_xftfont(x_display *xdpy, int pixsize, int orient, char *xftfont) +{ + /* xft font: all the font matching/opening/cache is done in here */ + Display *dpy = xdpy->dpy; + int ang, i, j; + int number; + + /* Use orient < 0 as positive angle for xft */ + if (orient>=0) ang = orient * 90; + else ang = -1 * orient; + + xdpy->xft_angle = ang; + + /* is the xft font in cache? */ + for (i=0;ixftfont = xftc[i].font; */ + xdpy->xftfont = XftFontCopy( dpy, xftc[i].font); + xdpy->xft_height = xftc[i].height; + return; + } + } + if (XFT_DEBUG) printf("\"%s\" not found in cache, generating\n",xftfont); + + /* Open pattern */ + XftPattern *xft_pat = XftNameParse(xftfont); + + /* Add pixel size and possible rotation */ + XftPatternAddDouble (xft_pat, XFT_PIXEL_SIZE, (double)pixsize); + + /* fisrt we need to get the ascent and descent of the unrotated font */ + + /* don't need to free the 2 following variables (checked), no memleak */ + XftPattern *match_pat; /* the best available match on the system */ + + /* query the system to find a match for this font */ + FcResult result; + match_pat = XftFontMatch(dpy, DefaultScreen(dpy), xft_pat, &result); + + /* open the matched font */ + xdpy->xftfont = XftFontOpenPattern(dpy, match_pat); + + /* store the height = ascent + descent for future use */ + xdpy->xft_height = xdpy->xftfont->ascent + xdpy->xftfont->descent; + + /* now we can go ahead for a possible rotation */ + + if (ang!=0) { + XftMatrix matrix; + XftMatrixInit(&matrix); + XftMatrixRotate(&matrix,cos(PI*(double)ang/180.),sin(PI*(double)ang/180.)); + XftPatternAddMatrix (xft_pat, XFT_MATRIX,&matrix); + + /* query the system to find a match for this font */ + match_pat = XftFontMatch(dpy, DefaultScreen(dpy), xft_pat, &result); + + /* we have to free space before we reallocate */ + XftFontClose( dpy, xdpy->xftfont); + + /* open the matched font */ + xdpy->xftfont = XftFontOpenPattern(dpy, match_pat); + } + + /* Tidy up the resources we allocated */ + XftPatternDestroy(xft_pat); + + /* Store in cache. I use pixsize as a used/not used marker. */ + /* Look for free slot */ + i=0; + while (ixftfont; + /* xftc[i].font = XftFontCopy( dpy, xdpy->xftfont); */ + xftc[i].dpy = dpy; + strcpy(xftc[i].name,xftfont); + xftc[i].angle = ang; + xftc[i].pixsize = pixsize; + xftc[i].height = xdpy->xft_height; +} +#endif + + + +void +p_text(p_win *w, int x0, int y0, const char *text, int n, int opaque) { p_scr *s = w->s; x_display *xdpy = s->xdpy; @@ -67,6 +241,13 @@ Drawable d = w->d; int i; +#ifdef HAVE_XFT + if (xft_enabled && xdpy->use_xft) { + p_xfttext(w, x0, y0, text, n, opaque); + return; + } +#endif + if (s->rotgc || s->tmp || s->image || s->pixmap!=None) x_rotzap(s); if (n<=0) n = 16350; @@ -157,3 +338,99 @@ } if (p_signalling) p_abort(); } + + +#ifdef HAVE_XFT +void +p_xfttext(p_win *w, int x0, int y0, const char *text, int n, int opaque) +{ + p_scr *s = w->s; + x_display *xdpy = s->xdpy; + Display *dpy = xdpy->dpy; + Drawable d = w->d; + XftFont *xftfont = xdpy->xftfont; + XGlyphInfo extents; + XftDraw *xftdraw; + XRenderColor xrcolor; + XftColor xftcolor, hlcolor; + int i; + + + + XftTextExtents8( dpy, xftfont, (XftChar8 *)text, strlen(text), &extents ); + + /* Xft draw context */ + xftdraw = XftDrawCreate( dpy, d, DefaultVisual(dpy,DefaultScreen(dpy)), + DefaultColormap( dpy, DefaultScreen(dpy) ) ); + + /* Colors: this really should not be here, but in colors.c, but I'm lazy */ + /* Xft text color */ + p_col_t col = x_getpixel(w,s->gc_color); + xrcolor.red = ((unsigned short)(char)(col>>16))<<7; + xrcolor.green = ((unsigned short)(char)(col>>8))<<7; + xrcolor.blue = ((unsigned short)(char)col)<<7; + xrcolor.alpha = 0xffff; + + XftColorAllocValue( dpy, DefaultVisual(dpy,DefaultScreen(dpy)), + DefaultColormap( dpy, DefaultScreen(dpy) ), + &xrcolor, &xftcolor ); + + /* Xft highlight color */ + if (opaque) { + col = x_getpixel(w,XFT_DEBUG? 251 : P_BG); + xrcolor.red = ((unsigned short)(char)(col>>16))<<7; + xrcolor.green = ((unsigned short)(char)(col>>8))<<7; + xrcolor.blue = ((unsigned short)(char)col)<<7; + xrcolor.alpha = 0xafff; + + XftColorAllocValue( dpy, DefaultVisual(dpy,DefaultScreen(dpy)), + DefaultColormap(dpy,DefaultScreen(dpy)), + &xrcolor, &hlcolor ); + + XftDrawRect( xftdraw, &hlcolor, x0-extents.x, y0-extents.y, + extents.width, extents.height); + } + if (n<=0) n = 16350; + for (i=0 ; i19) return ""; + return xftfonts[font]; +} + +#endif diff -Naur yorick/yorick/graph.c yorick-build/yorick/graph.c --- yorick/yorick/graph.c 2020-11-17 21:47:00.481399206 +1100 +++ yorick-build/yorick/graph.c 2020-11-17 21:47:00.544733804 +1100 @@ -60,6 +60,7 @@ long ix, long ijx, long *nbndy); extern BuiltIn Y_plg, Y_plm, Y_plc, Y_plv, Y_plf, Y_pli, Y_plt, Y_pldj; + extern BuiltIn Y_plmesh, Y_bytscl, Y_plfp; extern BuiltIn Y_limits, Y_logxy, Y_zoom_factor, Y_unzoom; @@ -77,7 +78,7 @@ extern BuiltIn Y_mouse, Y_contour, Y_mesh_loc, Y_pause, Y_current_window; extern BuiltIn Y_keybd_focus, Y_rgb_read; -extern BuiltIn Y_current_mouse, Y_set_gpath; +extern BuiltIn Y_current_mouse, Y_set_gpath, Y_xft; /*--------------------------------------------------------------------------*/ @@ -157,6 +158,8 @@ extern int YCurrentPlotter(void); /* for style.c */ +extern int xft_enabled; + /*--------------------------------------------------------------------------*/ static long yOrigin; @@ -412,8 +415,14 @@ return T_SYMBOL | GetTypeface(&s[6]); else if (strncmp(s, "schoolbook", 10)==0) return T_NEWCENTURY | GetTypeface(&s[10]); - YError("unrecognized font keyword"); - return 0; + else { +#ifdef HAVE_XFT + strncpy(gistA.t.xftfont,s,256); +#else + YError("unrecognized font keyword"); +#endif + return 0; + } } else { return (int)YGetInteger(stack); } @@ -1488,6 +1497,7 @@ Drop(nArgs+convertedZ); } + #undef N_KEYWORDS #define N_KEYWORDS 9 static char *pltKeys[N_KEYWORDS+1]= { @@ -1541,10 +1551,15 @@ if (gistA.t.orient==1) gistA.t.orient= TX_UP; else if (gistA.t.orient==2) gistA.t.orient= TX_LEFT; else if (gistA.t.orient==3) gistA.t.orient= TX_DOWN; - else { +#ifdef HAVE_XFT + /* orient < 0 allowed for xft angle */ + else if (gistA.t.orient>3) gistA.t.orient= TX_RIGHT; +#else + else if (gistA.t.orient>3 || gistA.t.orient<0) { gistA.t.orient= TX_RIGHT; YError("orient= keyword must be 0, 1, 2, or 3"); } +#endif } toSys= 0; @@ -2137,7 +2152,7 @@ else YError("failed to create drawing -- Gist work.gs style sheet missing"); } - + /* make this window current */ GhSetPlotter(n); @@ -2301,6 +2316,23 @@ } } + +void Y_xft(int argc) +{ + int n; + + if (argc > 1) { + YError("xft takes at most one non-keyword argument"); + } + if (YNotNil(sp)) { /* set xft_enabled */ + n = YGetInteger(sp); + xft_enabled = (n?1:0); + } else { /* return xft_enabled */ + PushIntValue(xft_enabled); + } +} + + #undef N_KEYWORDS #define N_KEYWORDS 2 static char *hcpKeys[N_KEYWORDS+1]= { "dump", "ps", 0 }; diff -Naur yorick/ysite.sh yorick-build/ysite.sh --- yorick/ysite.sh 2020-11-17 21:47:00.484732606 +1100 +++ yorick-build/ysite.sh 2020-11-17 21:47:00.551400604 +1100 @@ -1,8 +1,8 @@ #!/bin/sh -prefix="." +prefix="/usr" Y_PLATFORM="." Y_SITE="." -Y_HOME="relocate" +Y_HOME="." # -------------- DO NOT CHANGE THIS LINE OR BELOW ----------------------- # ysite.sh -- $Id: ysite.sh,v 1.4 2010-02-28 21:52:28 dhmunro Exp $