summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander F Rødseth2015-11-01 22:49:58 +0100
committerAlexander F Rødseth2015-11-01 22:49:58 +0100
commit42bb09993b55b1f486e1006ceeca7e1d61fc8501 (patch)
tree5a4a43378b5f00ee053cb207891fdfa5477427a8
downloadaur-42bb09993b55b1f486e1006ceeca7e1d61fc8501.tar.gz
Initial commit. Was lost in the transition to AUR4
-rw-r--r--.SRCINFO24
-rw-r--r--PKGBUILD48
-rw-r--r--yorick-cvs-pwin-border.patch20
-rw-r--r--yorick-cvs-xft-2012sep11.patch856
4 files changed, 948 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..25f7d537dfb2
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,24 @@
+# Generated by mksrcinfo v8
+# Sun Nov 1 21:49:41 UTC 2015
+pkgbase = yorick
+ pkgdesc = Interpreted language for data processing
+ pkgver = 2.2
+ pkgrel = 1
+ url = http://yorick.github.com/
+ arch = x86_64
+ arch = i686
+ groups = science
+ groups = yorick-all
+ license = BSD
+ makedepends = git
+ makedepends = pkgconfig
+ depends = rlwrap
+ source = git://github.com/dhmunro/yorick.git#commit=01e228e
+ source = https://raw.githubusercontent.com/mdcb/python-gist/master/patch/yorick-cvs-pwin-border.patch
+ source = https://raw.githubusercontent.com/frigaut/frigaut-arch-abs-files/master/yorick-cvs-xft-2012sep11.patch
+ md5sums = SKIP
+ md5sums = 4e486a0593cdedae8e44355d0b627abb
+ md5sums = 3cbd67fed39230c6a859ae601c1557f5
+
+pkgname = yorick
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..194577560b60
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Alexander Rødseth <rodseth@gmail.com>
+# Contributor: Francois Rigaut <frigaut@gmail.com>
+
+pkgname=yorick
+pkgver=2.2
+pkgrel=1
+pkgdesc='Interpreted language for data processing'
+arch=('x86_64' 'i686')
+license=('BSD')
+url='http://yorick.github.com/'
+groups=('science' 'yorick-all')
+depends=('rlwrap')
+makedepends=('git' 'pkgconfig')
+source=('git://github.com/dhmunro/yorick.git#commit=01e228e'
+ 'https://raw.githubusercontent.com/mdcb/python-gist/master/patch/yorick-cvs-pwin-border.patch'
+ 'https://raw.githubusercontent.com/frigaut/frigaut-arch-abs-files/master/yorick-cvs-xft-2012sep11.patch')
+md5sums=('SKIP'
+ '4e486a0593cdedae8e44355d0b627abb'
+ '3cbd67fed39230c6a859ae601c1557f5')
+
+prepare() {
+ cd yorick
+
+ patch -p1 -i ../yorick-cvs-xft-2012sep11.patch
+
+ make prefix=/usr ysite
+ make config
+
+ echo 'Y_CFLAGS=-DHAVE_XFT' >> Make.cfg
+ echo 'XINC=-I/usr/include/freetype2' >> Make.cfg
+ echo 'XLIB=-lXft' >> Make.cfg
+ echo 'X11LIB=$(XLIB) -lX11 -lfontconfig' >> Make.cfg
+
+ # Wrapper script for rlwrap and yorick
+ echo "#!/bin/sh" > wrap.sh
+ echo "exec rlwrap -s 2000 -c /usr/lib/yorick/$pkgver/bin/yorick \$*" >> wrap.sh
+}
+
+build() {
+ make -C yorick
+}
+
+package() {
+ make -C yorick INSTALL_ROOT="$pkgdir" install
+ install -DTm755 yorick/wrap.sh "$pkgdir/usr/bin/yorick"
+}
+
+# vim:set ts=2 sw=2 et:
diff --git a/yorick-cvs-pwin-border.patch b/yorick-cvs-pwin-border.patch
new file mode 100644
index 000000000000..9d43928b86c1
--- /dev/null
+++ b/yorick-cvs-pwin-border.patch
@@ -0,0 +1,20 @@
+--- src/play/x11/pwin.c 2010-07-06 16:21:49.000000000 -0400
++++ src/play/x11/pwin.c.new 2010-07-06 16:17:03.000000000 -0400
+@@ -139,7 +139,7 @@
+ p_col_t bg, int hints, void *ctx)
+ {
+ p_win *w = x_create(s, (Window)parent_id, hints, ctx,
+- x, y, width, height, 2, bg, PWIN_PLAIN);
++ x, y, width, height, 0, bg, PWIN_PLAIN);
+ if (w) {
+ Display *dpy = s->xdpy->dpy;
+ if (hints&P_RGBMODEL) x_rgb_palette(w);
+@@ -154,7 +154,7 @@
+ p_col_t bg, int hints, void *ctx)
+ {
+ p_win *w = x_create(s, s->root, hints, ctx,
+- 0, 0, width, height, 2, bg, PWIN_PLAIN);
++ 0, 0, width, height, 0, bg, PWIN_PLAIN);
+ if (w) {
+ XTextProperty x_title, *px_title;
+ Display *dpy = s->xdpy->dpy;
diff --git a/yorick-cvs-xft-2012sep11.patch b/yorick-cvs-xft-2012sep11.patch
new file mode 100644
index 000000000000..0699b4983cef
--- /dev/null
+++ b/yorick-cvs-xft-2012sep11.patch
@@ -0,0 +1,856 @@
+diff -uNr yorick-cvs/gist/gist.c yorick-xft/gist/gist.c
+--- yorick-cvs/gist/gist.c 2005-09-18 18:04:31.000000000 -0400
++++ yorick-xft/gist/gist.c 2010-11-01 21:44:12.000000000 -0300
+@@ -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 -uNr yorick-cvs/gist/gist.h yorick-xft/gist/gist.h
+--- yorick-cvs/gist/gist.h 2009-10-19 01:37:51.000000000 -0300
++++ yorick-xft/gist/gist.h 2010-11-02 21:54:24.000000000 -0300
+@@ -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 -uNr yorick-cvs/gist/hlevel.c yorick-xft/gist/hlevel.c
+--- yorick-cvs/gist/hlevel.c 2007-12-28 17:20:18.000000000 -0300
++++ yorick-xft/gist/hlevel.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/gist/xbasic.c yorick-xft/gist/xbasic.c
+--- yorick-cvs/gist/xbasic.c 2010-01-10 02:02:23.000000000 -0300
++++ yorick-xft/gist/xbasic.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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+1<nChars && c=='!') || c=='^' || c=='_') break;
+ }
+- 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&= 3;
+ } else {
+ /* chunk is single symbol char */
+- p_font(current_win, current_fsym, current_fsize, gistA.t.orient);
++ p_font(current_win, current_fsym, current_fsize,
++ gistA.t.orient, gistA.t.xftfont);
+ current_state|= 4;
+ }
+
+@@ -372,7 +376,8 @@
+ if ((nChunk+1<nChars && c=='!') || c=='^' || c=='_') break;
+ }
+ if (nChunk)
+- 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);
+ if (c1=='^') {
+ if (current_state&1) {
+ yadj+= dy_super; /* return from super to normal */
+@@ -809,7 +814,9 @@
+ /* erase background if string is opaque */
+ if (gistA.t.opaque) {
+ p_color(w, P_BG);
+- p_rect(w, xbox[0], ybox[0], xbox[1], ybox[1], 0);
++ /* when using xft, the opaque is managed by textout */
++ if (!strlen(gistA.t.xftfont))
++ p_rect(w, xbox[0], ybox[0], xbox[1], ybox[1], 0);
+ }
+ p_color(w, gistA.t.color);
+
+@@ -817,7 +824,7 @@
+ if (len>0) {
+ 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 -uNr yorick-cvs/gist/xfancy.c yorick-xft/gist/xfancy.c
+--- yorick-cvs/gist/xfancy.c 2008-10-28 01:02:30.000000000 -0300
++++ yorick-xft/gist/xfancy.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/i/style.i yorick-xft/i/style.i
+--- yorick-cvs/i/style.i 2005-09-18 18:06:10.000000000 -0400
++++ yorick-xft/i/style.i 2010-11-02 21:54:34.000000000 -0300
+@@ -342,10 +342,10 @@
+ default_line= GpLineAttribs(color= 254, type= 1, width= 1.0);
+ default_text= GpTextAttribs(
+ color= 254, font= 0x08, height= 0.0182,
+- orient= 0, alignH= 0, alignV= 0, opaque= 0);
++ orient= 0, alignH= 0, alignV= 0, opaque= 0);
+ default_ltxt= GpTextAttribs(
+ color= 254, font= 0x00, height= 0.0156,
+- orient= 0, alignH= 1, alignV= 1, opaque= 0);
++ orient= 0, alignH= 1, alignV= 1, opaque= 0);
+ default= GfakeSystem(viewport=[0.19, 0.60, 0.44, 0.85],
+ ticks= GaTickStyle(
+ horiz= GaAxisStyle(
+@@ -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 -uNr yorick-cvs/i0/graph.i yorick-xft/i0/graph.i
+--- yorick-cvs/i0/graph.i 2010-04-18 06:33:38.000000000 -0400
++++ yorick-xft/i0/graph.i 2010-11-01 16:53:54.000000000 -0300
+@@ -697,6 +697,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 ====================================*/
+
+@@ -1349,6 +1369,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: "<family>-<size>:<name>=<value>...", 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
+@@ -1357,10 +1391,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 -uNr yorick-cvs/opengl/test3d.c yorick-xft/opengl/test3d.c
+--- yorick-cvs/opengl/test3d.c 2005-09-18 18:06:23.000000000 -0400
++++ yorick-xft/opengl/test3d.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/play/play.h yorick-xft/play/play.h
+--- yorick-cvs/play/play.h 2010-04-08 06:53:49.000000000 -0400
++++ yorick-xft/play/play.h 2010-11-01 16:53:54.000000000 -0300
+@@ -119,7 +119,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)
+@@ -133,7 +133,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 -uNr yorick-cvs/play/README yorick-xft/play/README
+--- yorick-cvs/play/README 2007-03-19 03:31:30.000000000 -0400
++++ yorick-xft/play/README 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/play/win/getdc.c yorick-xft/play/win/getdc.c
+--- yorick-cvs/play/win/getdc.c 2005-09-18 18:05:35.000000000 -0400
++++ yorick-xft/play/win/getdc.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/play/win/ptext.c yorick-xft/play/win/ptext.c
+--- yorick-cvs/play/win/ptext.c 2005-09-18 18:05:36.000000000 -0400
++++ yorick-xft/play/win/ptext.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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 -uNr yorick-cvs/play/x11/connect.c yorick-xft/play/x11/connect.c
+--- yorick-cvs/play/x11/connect.c 2005-09-18 18:05:34.000000000 -0400
++++ yorick-xft/play/x11/connect.c 2010-11-02 22:35:49.000000000 -0300
+@@ -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 ; i<N_XFTFONT_CACHE ; i++) {
++ xftc[i].pixsize = 0;
++ xftc[i].dpy = 0;
++ xftc[i].angle = 0;
++ xftc[i].height = 0;
++ }
++#endif
+ /* find default font */
+
+ if (x_xfont) {
+@@ -222,6 +230,17 @@
+ xdpy->cached[i].f = 0;
+ XFreeFont(dpy, font);
+ }
++
++#ifdef HAVE_XFT
++ /* XftFontClose( dpy, xdpy->xftfont); */
++ for (i=0 ; i<N_XFTFONT_CACHE ; i++) {
++ if (xftc[i].pixsize) {
++ xftc[i].pixsize = 0;
++ if (xftc[i].dpy==dpy) XftFontClose(dpy, xftc[i].font);
++ }
++ }
++#endif
++
+ for (i=0 ; i<=P_NONE ; i++) {
+ cur = xdpy->cursors[i];
+ xdpy->cursors[i] = None;
+diff -uNr yorick-cvs/play/x11/playwin.h yorick-xft/play/x11/playwin.h
+--- yorick-cvs/play/x11/playwin.h 2005-09-18 18:05:34.000000000 -0400
++++ yorick-xft/play/x11/playwin.h 2010-11-02 21:51:05.000000000 -0300
+@@ -11,7 +11,20 @@
+ #include "play.h"
+ #include "phash.h"
+ #include <X11/Xlib.h>
+-
++#ifdef HAVE_XFT
++#include <X11/Xft/Xft.h>
++#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 -uNr yorick-cvs/play/x11/playx.h yorick-xft/play/x11/playx.h
+--- yorick-cvs/play/x11/playx.h 2005-09-18 18:05:32.000000000 -0400
++++ yorick-xft/play/x11/playx.h 2010-11-02 21:17:53.000000000 -0300
+@@ -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 -uNr yorick-cvs/play/x11/textout.c yorick-xft/play/x11/textout.c
+--- yorick-cvs/play/x11/textout.c 2005-09-18 18:05:33.000000000 -0400
++++ yorick-xft/play/x11/textout.c 2010-11-02 22:47:19.000000000 -0300
+@@ -10,32 +10,100 @@
+
+ #include "config.h"
+ #include "playx.h"
+-
+ #include "pstdlib.h"
+-
+ #include <string.h>
+
++#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];
++#endif
++int xft_enabled;
++
++
+ 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 +124,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;i<N_XFTFONT_CACHE;i++) {
++ if (xftc[i].pixsize && xftc[i].pixsize == pixsize &&
++ xftc[i].angle == ang && xftc[i].dpy == dpy &&
++ strcmp(xftc[i].name,xftfont) == 0 ) {
++ if (XFT_DEBUG) printf("Found a match for \"%s\" in cache\n",xftfont);
++ /* xdpy->xftfont = 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 */
++ XftResult fcresult;
++ match_pat = XftFontMatch(dpy, DefaultScreen(dpy), xft_pat, &fcresult);
++
++ /* 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, &fcresult);
++
++ /* 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 (i<N_XFTFONT_CACHE && xftc[i].pixsize) i++;
++
++ if (i==N_XFTFONT_CACHE) {
++ /* Cache is full, empying */
++ if (XFT_DEBUG) printf("Font cache out of space, clearing the cache\n");
++ /* I choose to clear the whole cache instead of removing only the */
++ /* most recent like the regular font cache. Not a big deal. */
++ for (j=0;j<N_XFTFONT_CACHE;j++) {
++ strcpy(xftc[j].name,"");
++ xftc[j].pixsize = 0;
++ XftFontClose(xftc[j].dpy, xftc[j].font);
++ }
++ i=0;
++ }
++
++ /* Store font in cache */
++ if (XFT_DEBUG) printf("Storing \"%s\" in cache[%d]\n",xftfont,i);
++ xftc[i].font = xdpy->xftfont;
++ /* 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 +238,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 +335,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 ; i<n ; i++) if (!text[i]) break;
++ n = i;
++
++ /* Finally, draw the text: */
++ XftDrawString8( xftdraw, &xftcolor, xftfont, x0, y0, (XftChar8 *)text, n );
++
++ // Tidy up the resources we allocated
++ XftColorFree ( dpy, DefaultVisual(dpy,DefaultScreen(dpy)),
++ DefaultColormap(dpy,DefaultScreen(dpy)),&hlcolor);
++ XftColorFree ( dpy, DefaultVisual(dpy,DefaultScreen(dpy)),
++ DefaultColormap(dpy,DefaultScreen(dpy)),&xftcolor);
++ XftDrawDestroy( xftdraw );
++}
++
++char *
++p_font2xftfont(int font)
++{
++ static char *xftfonts[20] =
++ {"Courier",
++ "Courier:weight=255",
++ "Courier:slant=1",
++ "Courier:weight=255:slant=1",
++ "Times",
++ "Times:weight=255",
++ "Times:slant=1",
++ "Times:weight=255:slant=1",
++ "Helvetica",
++ "Helvetica:weight=255",
++ "Helvetica:slant=1",
++ "Helvetica:weight=255:slant=1",
++ "Symbol",
++ "Symbol:weight=255",
++ "Symbol:slant=1",
++ "Symbol:weight=255:slant=1",
++ "New Century Schoolbook",
++ "New Century Schoolbook:weight=255",
++ "New Century Schoolbook:slant=1",
++ "New Century Schoolbook:weight=255:slant=1"};
++ if (font<0 || font>19) return "";
++ return xftfonts[font];
++}
++
++#endif
+diff -uNr yorick-cvs/yorick/graph.c yorick-xft/yorick/graph.c
+--- yorick-cvs/yorick/graph.c 2010-04-13 07:34:30.000000000 -0400
++++ yorick-xft/yorick/graph.c 2010-11-01 16:53:54.000000000 -0300
+@@ -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;
+
+ /*--------------------------------------------------------------------------*/
+
+@@ -156,6 +157,11 @@
+ static void RefMesh(GaQuadMesh *mesh);
+
+ extern int YCurrentPlotter(void); /* for style.c */
++#ifdef HAVE_XFT
++extern int xft_enabled=1;
++#else
++extern int xft_enabled=-1;
++#endif
+
+ /*--------------------------------------------------------------------------*/
+
+@@ -410,8 +416,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);
+ }
+@@ -1486,6 +1498,7 @@
+ Drop(nArgs+convertedZ);
+ }
+
++
+ #undef N_KEYWORDS
+ #define N_KEYWORDS 9
+ static char *pltKeys[N_KEYWORDS+1]= {
+@@ -1539,10 +1552,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;
+@@ -2135,7 +2153,7 @@
+ else
+ YError("failed to create drawing -- Gist work.gs style sheet missing");
+ }
+-
++
+ /* make this window current */
+ GhSetPlotter(n);
+
+@@ -2301,6 +2319,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 };