From f911758e4bb6bea8dd3830f2d187eec651bd5818 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Tue, 18 Aug 2020 09:43:11 +0200 Subject: [PATCH] X11: re-enable writing text to a graph if libxft is used --- src/frontend/plotting/x11.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 1952e0b36..5c6485047 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -361,9 +361,24 @@ handlekeypressed(Widget w, XtPointer client_data, XEvent *ev, Boolean *continue_ /* save it */ SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); /* warp mouse so user can type in sequence */ +#ifndef HAVE_LIBXFT XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), keyev->y); +#else + int wl, wh; + int ret = Xget_str_length("ABCD", &wl, &wh, NULL, DEVDEP(graph).fname, DEVDEP(graph).fsize); + if (ret == 1) + ret = Xget_str_length("ζˆ‘θƒ½εžδΈ‹", &wl, &wh, NULL, DEVDEP(graph).fname, DEVDEP(graph).fsize); + if (ret == 1) { + fprintf(cp_err, "Error: Could not establish a font for %s\n", DEVDEP(graph).fname); + goto end; + } + XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, + keyev->x + wl*nbytes/4, + keyev->y); +#endif +end: PopGraphContext(); }