replace old_x11 by HAVE_LIBXFT defined in configure
This commit is contained in:
parent
3031cb5f65
commit
bbf11e0bd3
|
|
@ -1338,7 +1338,7 @@ static char *inp_pathresolve(const char *name)
|
||||||
if (stat(name, &st) == 0)
|
if (stat(name, &st) == 0)
|
||||||
return copy(name);
|
return copy(name);
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
#if !defined(EXT_ASC) && (defined(__MINGW32__) || defined(_MSC_VER))
|
||||||
wchar_t wname[BSIZE_SP];
|
wchar_t wname[BSIZE_SP];
|
||||||
if (MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, 2 * (int)strlen(name) + 1) == 0) {
|
if (MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, 2 * (int)strlen(name) + 1) == 0) {
|
||||||
fprintf(stderr, "UTF-8 to UTF-16 conversion failed with 0x%x\n", GetLastError());
|
fprintf(stderr, "UTF-8 to UTF-16 conversion failed with 0x%x\n", GetLastError());
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,9 @@ typedef tWindowData *tpWindowData; /* pointer to it */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef X_DISPLAY_MISSING
|
#ifndef X_DISPLAY_MISSING
|
||||||
extern bool old_x11;
|
|
||||||
extern int X11_GetLenStr(GRAPH *gr, char* instring);
|
extern int X11_GetLenStr(GRAPH *gr, char* instring);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef X_DISPLAY_MISSING
|
|
||||||
extern bool old_x11;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RAD_TO_DEG (180.0 / M_PI)
|
#define RAD_TO_DEG (180.0 / M_PI)
|
||||||
#define RELPOSXUNIT 0.6 /* old position of the UNIT label */
|
#define RELPOSXUNIT 0.6 /* old position of the UNIT label */
|
||||||
|
|
||||||
|
|
@ -163,10 +158,12 @@ gr_redrawgrid(GRAPH *graph)
|
||||||
wlen++;
|
wlen++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
/* string lenth in pixels */
|
/* string lenth in pixels */
|
||||||
int strsize = X11_GetLenStr(graph, graph->grid.xlabel);
|
int strsize = X11_GetLenStr(graph, graph->grid.xlabel);
|
||||||
DevDrawText(graph->grid.xlabel,
|
DevDrawText(graph->grid.xlabel,
|
||||||
(int)((graph->absolute.width - strsize) / 2), graph->fontheight, 0);
|
(int)((graph->absolute.width - strsize) / 2), graph->fontheight, 0);
|
||||||
|
|
||||||
/* fix the position of the UNIT label */
|
/* fix the position of the UNIT label */
|
||||||
if (RELPOSXUNIT * graph->absolute.width < ((graph->absolute.width + strsize) / 2 + graph->fontwidth))
|
if (RELPOSXUNIT * graph->absolute.width < ((graph->absolute.width + strsize) / 2 + graph->fontwidth))
|
||||||
unitshift = (int)((graph->absolute.width + strsize) / 2
|
unitshift = (int)((graph->absolute.width + strsize) / 2
|
||||||
|
|
@ -174,6 +171,12 @@ gr_redrawgrid(GRAPH *graph)
|
||||||
+ graph->fontwidth;
|
+ graph->fontwidth;
|
||||||
else
|
else
|
||||||
unitshift = 0; /* reset for next plot window */
|
unitshift = 0; /* reset for next plot window */
|
||||||
|
#else
|
||||||
|
DevDrawText(graph->grid.xlabel,
|
||||||
|
(int) (graph->absolute.width * 0.35), graph->fontheight,
|
||||||
|
0);
|
||||||
|
unitshift = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_WINGUI
|
#ifdef HAS_WINGUI
|
||||||
|
|
@ -256,21 +259,20 @@ gr_redrawgrid(GRAPH *graph)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef X_DISPLAY_MISSING
|
|
||||||
/* new x11 with xft and utf-8 */
|
|
||||||
else if (!old_x11) {
|
|
||||||
/* calculate and add offsets in fcn X11_Text in X11.c */
|
|
||||||
DevDrawText(graph->grid.ylabel,
|
|
||||||
0,
|
|
||||||
/*vertical text, y is midpoint of graph height */
|
|
||||||
(graph->absolute.height) / 2, 90);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
else /* others */
|
else /* others */
|
||||||
DevDrawText(graph->grid.ylabel,
|
DevDrawText(graph->grid.ylabel,
|
||||||
graph->fontwidth,
|
#if !defined(X_DISPLAY_MISSING) && defined(HAVE_LIBXFT)
|
||||||
graph->absolute.height / 2, 90);
|
/* new x11 with xft and utf-8
|
||||||
|
* calculate and add offsets in fcn X11_Text in X11.c
|
||||||
|
*/
|
||||||
|
0,
|
||||||
|
#else
|
||||||
|
graph->fontwidth,
|
||||||
|
#endif
|
||||||
|
/*vertical text, y is midpoint of graph height */
|
||||||
|
graph->absolute.height / 2, 90);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ Author: 1988 Jeffrey M. Hsu
|
||||||
# include <X11/Shell.h>
|
# include <X11/Shell.h>
|
||||||
# include <X11/Intrinsic.h>
|
# include <X11/Intrinsic.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
# include <X11/Xlib.h> /* for _Xdebug */
|
# include <X11/Xlib.h> /* for _Xdebug */
|
||||||
|
|
@ -60,8 +62,6 @@ Author: 1988 Jeffrey M. Hsu
|
||||||
|
|
||||||
#define NUMCOLORS 20
|
#define NUMCOLORS 20
|
||||||
|
|
||||||
bool old_x11 = FALSE; /* if FALSE, use xft, if TRUE use old X11 text output */
|
|
||||||
|
|
||||||
typedef struct x11info {
|
typedef struct x11info {
|
||||||
Window window;
|
Window window;
|
||||||
int isopen;
|
int isopen;
|
||||||
|
|
@ -71,16 +71,18 @@ typedef struct x11info {
|
||||||
int lastx, lasty; /* used in X_DrawLine */
|
int lastx, lasty; /* used in X_DrawLine */
|
||||||
int lastlinestyle; /* used in X_DrawLine */
|
int lastlinestyle; /* used in X_DrawLine */
|
||||||
Pixel colors[NUMCOLORS];
|
Pixel colors[NUMCOLORS];
|
||||||
/* use with xft */
|
|
||||||
char txtcolor[16];
|
char txtcolor[16];
|
||||||
char bgcolor[16];
|
char bgcolor[16];
|
||||||
char fname[BSIZE_SP];
|
char fname[BSIZE_SP];
|
||||||
int fsize;
|
int fsize;
|
||||||
|
/* use with xft */
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
XftFont *font0;
|
XftFont *font0;
|
||||||
XftFont *font90;
|
XftFont *font90;
|
||||||
XftDraw* draw;
|
XftDraw* draw;
|
||||||
XftColor color;
|
XftColor color;
|
||||||
Colormap cmap;
|
Colormap cmap;
|
||||||
|
#endif
|
||||||
} X11devdep;
|
} X11devdep;
|
||||||
|
|
||||||
#define DEVDEP(g) (*((X11devdep *) (g)->devdep))
|
#define DEVDEP(g) (*((X11devdep *) (g)->devdep))
|
||||||
|
|
@ -116,9 +118,10 @@ static void X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy);
|
||||||
static void linear_arc(int x0, int y0, int radius, double theta, double delta_theta);
|
static void linear_arc(int x0, int y0, int radius, double theta, double delta_theta);
|
||||||
static void slopelocation(GRAPH *graph, int x0, int y0);
|
static void slopelocation(GRAPH *graph, int x0, int y0);
|
||||||
static void zoomin(GRAPH *graph);
|
static void zoomin(GRAPH *graph);
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
static int Xget_str_length(char *text, int* wlen, int* wheight, XftFont* gfont, char* name, int fsize);
|
static int Xget_str_length(char *text, int* wlen, int* wheight, XftFont* gfont, char* name, int fsize);
|
||||||
static int X11_DefineXft(GRAPH *graph);
|
static int X11_DefineXft(GRAPH *graph);
|
||||||
|
#endif
|
||||||
//XtEventHandler
|
//XtEventHandler
|
||||||
static void handlekeypressed(Widget w, XtPointer clientdata, XEvent *ev, Boolean *continue_dispatch);
|
static void handlekeypressed(Widget w, XtPointer clientdata, XEvent *ev, Boolean *continue_dispatch);
|
||||||
static void handlebuttonev(Widget w, XtPointer graph, XEvent *ev, Boolean *continue_dispatch);
|
static void handlebuttonev(Widget w, XtPointer graph, XEvent *ev, Boolean *continue_dispatch);
|
||||||
|
|
@ -158,9 +161,6 @@ X11_Init(void)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp_getvar("old_x11", CP_BOOL, NULL, 0))
|
|
||||||
old_x11 = TRUE;
|
|
||||||
|
|
||||||
# ifdef DEBUG
|
# ifdef DEBUG
|
||||||
_Xdebug = 1;
|
_Xdebug = 1;
|
||||||
# endif
|
# endif
|
||||||
|
|
@ -259,12 +259,13 @@ initcolors(GRAPH *graph)
|
||||||
(void) sprintf(buf, "color%d", i);
|
(void) sprintf(buf, "color%d", i);
|
||||||
if (!cp_getvar(buf, CP_STRING, colorstring, sizeof(colorstring)))
|
if (!cp_getvar(buf, CP_STRING, colorstring, sizeof(colorstring)))
|
||||||
(void) strcpy(colorstring, colornames[i]);
|
(void) strcpy(colorstring, colornames[i]);
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
/* text color info for xft */
|
/* text color info for xft */
|
||||||
if((!old_x11) && (i == 1))
|
if (i == 1)
|
||||||
strncpy(DEVDEP(graph).txtcolor, colorstring, 15);
|
strncpy(DEVDEP(graph).txtcolor, colorstring, 15);
|
||||||
else if((!old_x11) && (i == 0))
|
else if (i == 0)
|
||||||
strncpy(DEVDEP(graph).bgcolor, colorstring, 15);
|
strncpy(DEVDEP(graph).bgcolor, colorstring, 15);
|
||||||
|
#endif
|
||||||
if (!XAllocNamedColor(display,
|
if (!XAllocNamedColor(display,
|
||||||
DefaultColormap(display, DefaultScreen(display)),
|
DefaultColormap(display, DefaultScreen(display)),
|
||||||
colorstring, &visualcolor, &exactcolor)) {
|
colorstring, &visualcolor, &exactcolor)) {
|
||||||
|
|
@ -461,45 +462,44 @@ X11_NewViewport(GRAPH *graph)
|
||||||
(void) strcpy(fontname, DEF_FONT);
|
(void) strcpy(fontname, DEF_FONT);
|
||||||
strncpy(DEVDEP(graph).fname, fontname, BSIZE_SP - 1);
|
strncpy(DEVDEP(graph).fname, fontname, BSIZE_SP - 1);
|
||||||
|
|
||||||
if(old_x11) {
|
#ifndef HAVE_LIBXFT
|
||||||
for (p = fontname; *p && *p <= ' '; p++)
|
for (p = fontname; *p && *p <= ' '; p++)
|
||||||
;
|
;
|
||||||
|
|
||||||
if (p != fontname) {
|
if (p != fontname) {
|
||||||
for (q = fontname; *p; *q++ = *p++)
|
for (q = fontname; *p; *q++ = *p++)
|
||||||
;
|
;
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
}
|
|
||||||
trys = 1;
|
|
||||||
while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) {
|
|
||||||
sprintf(ErrorMessage, "can't open font %s", fontname);
|
|
||||||
strcpy(fontname, "fixed");
|
|
||||||
if (trys > 1) {
|
|
||||||
internalerror(ErrorMessage);
|
|
||||||
RECOVERNEWVIEWPORT();
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
trys += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
trys = 1;
|
||||||
|
while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) {
|
||||||
|
sprintf(ErrorMessage, "can't open font %s", fontname);
|
||||||
|
strcpy(fontname, "fixed");
|
||||||
|
if (trys > 1) {
|
||||||
|
internalerror(ErrorMessage);
|
||||||
|
RECOVERNEWVIEWPORT();
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
trys += 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* font size */
|
/* font size */
|
||||||
if (!cp_getvar("xfont_size", CP_NUM, &xfont_size, 0))
|
if (!cp_getvar("xfont_size", CP_NUM, &xfont_size, 0))
|
||||||
xfont_size = 16;
|
xfont_size = 16;
|
||||||
|
|
||||||
if(old_x11) {
|
#ifndef HAVE_LIBXFT
|
||||||
graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing -
|
graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing -
|
||||||
DEVDEP(graph).font->min_bounds.lbearing + 1;
|
DEVDEP(graph).font->min_bounds.lbearing + 1;
|
||||||
graph->fontheight = DEVDEP(graph).font->max_bounds.ascent +
|
graph->fontheight = DEVDEP(graph).font->max_bounds.ascent +
|
||||||
DEVDEP(graph).font->max_bounds.descent + 1;
|
DEVDEP(graph).font->max_bounds.descent + 1;
|
||||||
}
|
#else
|
||||||
else {
|
int wl, wh;
|
||||||
int wl, wh;
|
Xget_str_length("ABCD", &wl, &wh, NULL, fontname, xfont_size);
|
||||||
Xget_str_length("ABCD", &wl, &wh, NULL, fontname, xfont_size);
|
graph->fontwidth = (int)(wl / 4);
|
||||||
graph->fontwidth = (int)(wl / 4);
|
graph->fontheight = wh;
|
||||||
graph->fontheight = wh;
|
DEVDEP(graph).fsize = xfont_size;
|
||||||
DEVDEP(graph).fsize = xfont_size;
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
XtRealizeWidget(DEVDEP(graph).shell);
|
XtRealizeWidget(DEVDEP(graph).shell);
|
||||||
|
|
||||||
|
|
@ -513,15 +513,14 @@ X11_NewViewport(GRAPH *graph)
|
||||||
gcvalues.line_width = MW_LINEWIDTH;
|
gcvalues.line_width = MW_LINEWIDTH;
|
||||||
gcvalues.cap_style = CapNotLast;
|
gcvalues.cap_style = CapNotLast;
|
||||||
gcvalues.function = GXcopy;
|
gcvalues.function = GXcopy;
|
||||||
if (old_x11) {
|
#ifndef HAVE_LIBXFT
|
||||||
gcvalues.font = DEVDEP(graph).font->fid;
|
gcvalues.font = DEVDEP(graph).font->fid;
|
||||||
DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window,
|
DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window,
|
||||||
GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues);
|
GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues);
|
||||||
}
|
#else
|
||||||
else
|
DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window,
|
||||||
DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window,
|
GCLineWidth | GCCapStyle | GCFunction, &gcvalues);
|
||||||
GCLineWidth | GCCapStyle | GCFunction, &gcvalues);
|
#endif
|
||||||
|
|
||||||
/* should absolute.positions really be shell.pos? */
|
/* should absolute.positions really be shell.pos? */
|
||||||
graph->absolute.xpos = DEVDEP(graph).view->core.x;
|
graph->absolute.xpos = DEVDEP(graph).view->core.x;
|
||||||
graph->absolute.ypos = DEVDEP(graph).view->core.y;
|
graph->absolute.ypos = DEVDEP(graph).view->core.y;
|
||||||
|
|
@ -535,7 +534,9 @@ X11_NewViewport(GRAPH *graph)
|
||||||
cursor = XCreateFontCursor(display, XC_left_ptr);
|
cursor = XCreateFontCursor(display, XC_left_ptr);
|
||||||
XDefineCursor(display, DEVDEP(graph).window, cursor);
|
XDefineCursor(display, DEVDEP(graph).window, cursor);
|
||||||
|
|
||||||
X11_DefineXft(graph);
|
#ifdef HAVE_LIBXFT
|
||||||
|
X11_DefineXft(graph);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* WM_DELETE_WINDOW protocol */
|
/* WM_DELETE_WINDOW protocol */
|
||||||
atom_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
|
atom_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
|
||||||
|
|
@ -614,7 +615,7 @@ X11_Text(char *text, int x, int y, int angle)
|
||||||
|
|
||||||
int wlen = 0, wheight = 0;
|
int wlen = 0, wheight = 0;
|
||||||
|
|
||||||
if(old_x11) {
|
#ifndef HAVE_LIBXFT
|
||||||
if (DEVDEP(currentgraph).isopen)
|
if (DEVDEP(currentgraph).isopen)
|
||||||
XDrawString(display, DEVDEP(currentgraph).window,
|
XDrawString(display, DEVDEP(currentgraph).window,
|
||||||
DEVDEP(currentgraph).gc, x,
|
DEVDEP(currentgraph).gc, x,
|
||||||
|
|
@ -623,9 +624,7 @@ X11_Text(char *text, int x, int y, int angle)
|
||||||
text, (int) strlen(text));
|
text, (int) strlen(text));
|
||||||
|
|
||||||
/* note: unlike before, we do not save any text here */
|
/* note: unlike before, we do not save any text here */
|
||||||
return 0;
|
#else
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw text */
|
/* Draw text */
|
||||||
if(angle == 0) {
|
if(angle == 0) {
|
||||||
XftDrawStringUtf8(
|
XftDrawStringUtf8(
|
||||||
|
|
@ -644,10 +643,11 @@ X11_Text(char *text, int x, int y, int angle)
|
||||||
else
|
else
|
||||||
fprintf(stderr, " Xft: angles other than 0 or 90 are not supported in ngspice\n");
|
fprintf(stderr, " Xft: angles other than 0 or 90 are not supported in ngspice\n");
|
||||||
|
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
int X11_DefineXft(GRAPH *graph)
|
int X11_DefineXft(GRAPH *graph)
|
||||||
{
|
{
|
||||||
/* font selection with rotation */
|
/* font selection with rotation */
|
||||||
|
|
@ -685,6 +685,7 @@ int X11_DefineXft(GRAPH *graph)
|
||||||
);
|
);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
X11_DefineColor(int colorid, double red, double green, double blue)
|
X11_DefineColor(int colorid, double red, double green, double blue)
|
||||||
|
|
@ -1025,14 +1026,16 @@ void RemoveWindow(GRAPH *graph)
|
||||||
/* MW. Not sure but DestroyGraph might free() too much - try Xt...() first */
|
/* MW. Not sure but DestroyGraph might free() too much - try Xt...() first */
|
||||||
XtUnmapWidget(DEVDEP(graph).shell);
|
XtUnmapWidget(DEVDEP(graph).shell);
|
||||||
XtDestroyWidget(DEVDEP(graph).shell);
|
XtDestroyWidget(DEVDEP(graph).shell);
|
||||||
if (old_x11)
|
#ifndef HAVE_LIBXFT
|
||||||
XFreeFont(display, DEVDEP(graph).font);
|
XFreeFont(display, DEVDEP(graph).font);
|
||||||
|
#endif
|
||||||
XFreeGC(display, DEVDEP(graph).gc);
|
XFreeGC(display, DEVDEP(graph).gc);
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
XftFontClose( display, DEVDEP(graph).font0);
|
XftFontClose( display, DEVDEP(graph).font0);
|
||||||
XftFontClose( display, DEVDEP(graph).font90);
|
XftFontClose( display, DEVDEP(graph).font90);
|
||||||
XftDrawDestroy(DEVDEP(graph).draw);
|
XftDrawDestroy(DEVDEP(graph).draw);
|
||||||
XftColorFree(display, DefaultVisual(display, 0), DEVDEP(graph).cmap, &DEVDEP(graph).color);
|
XftColorFree(display, DefaultVisual(display, 0), DEVDEP(graph).cmap, &DEVDEP(graph).color);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graph == currentgraph)
|
if (graph == currentgraph)
|
||||||
|
|
@ -1230,6 +1233,7 @@ linear_arc(int x0, int y0, int radius, double theta, double delta_theta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBXFT
|
||||||
/* After font selection for XftTextExtentsUtf8
|
/* After font selection for XftTextExtentsUtf8
|
||||||
* to measure character string length.
|
* to measure character string length.
|
||||||
* Same as rotation below, but 0° angle */
|
* Same as rotation below, but 0° angle */
|
||||||
|
|
@ -1265,6 +1269,7 @@ X11_GetLenStr(GRAPH *gr, char* instring)
|
||||||
Xget_str_length(instring, &wl, &wh, NULL, DEVDEP(gr).fname, DEVDEP(gr).fsize);
|
Xget_str_length(instring, &wl, &wh, NULL, DEVDEP(gr).fname, DEVDEP(gr).fsize);
|
||||||
return wl;
|
return wl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue