[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuplot-info-beta
Subject: PATCH: X11 support for font changes [was: Embed Type1 fontfile for postscript]
From: Ethan Merritt <merritt () u ! washington ! edu>
Date: 2002-08-19 3:04:32
[Download RAW message or body]
I went ahead and added minimal support for changing fonts during
an X11 terminal session. Patch is attached.
I take back what I said about the gnuplot/gnuplot_x11 interface being
an arcane tangle. It's not so bad. I'm still confused by the fact that
there seem to be 3 X11 driver variants intermingled in the one source
file. The changes I made apply to "set term x11" (the default).
Sample commands that now work for X11:
set label 1 "Label 1" font "lucidasans-bolditalic-14"
set label 2 "Label 2" font "lucidasans-18"
Given the way X11 font names work, if you want to be able to
specify the font size separately (e.g. font "lucidasans,11")
then you will have to add a bunch of aliases to your X11
font lists. This place to do this is system-dependent, but
a typical place is
/usr/X11R6/lib/X11/fonts/100dpi/fonts.alias
/usr/X11R6/lib/X11/fonts/75dpi/fonts.alias
There you will find existing lines like
lucidasans-bold-8 -b&h-lucida-bold-r-normal-sans-11-80-100-100-p-70-iso8859-1
lucidasans-bold-10 -b&h-lucida-bold-r-normal-sans-14-100-100-100-p-89-iso8859-1
You could add the equivalent gnuplot-style aliases with comma-separated size:
lucidasans-bold,8 -b&h-lucida-bold-r-normal-sans-11-80-100-100-p-70-iso8859-1
lucidasans-bold,10 -b&h-lucida-bold-r-normal-sans-14-100-100-100-p-89-iso8859-1
The new aliases would take effect the next time the X server
restarts. The command 'xlsfonts' will print out a list of all fonts currently
known to the X server.
On Saturday 17 August 2002 13:44, Petr Mikulik wrote:
>
> Then how does other X11 programs do rotate text? Maybe it uses the
> same trick as Johannes used for 90deg rotation --- a matrix?
The use the font support in higher-level libraries like libfreetype.
I don't know of any way to rotate text using just the basic X11R6 libraries.
But I'm not an X expert, so maybe I'm overlooking something.
--
Ethan A Merritt merritt@u.washington.edu
Biomolecular Structure Center Box 357742
University of Washington, Seattle, WA 98195
phone: (206)543-1421
FAX: (206)685-7002
["x11fonts_18aug2002.patch" (text/x-diff)]
--- gnuplot/term/x11.trm Fri Jul 26 16:20:23 2002
+++ gnuplot-eam/term/x11.trm Sun Aug 18 17:31:00 2002
@@ -61,6 +61,7 @@
TERM_PUBLIC void X11_init __PROTO((void));
TERM_PUBLIC void X11_graphics __PROTO((void));
TERM_PUBLIC void X11_text __PROTO((void));
+TERM_PUBLIC int X11_set_font __PROTO((const char * fontname));
TERM_PUBLIC void X11_reset __PROTO((void));
TERM_PUBLIC void X11_move __PROTO((unsigned int x, unsigned int y));
TERM_PUBLIC void X11_vector __PROTO((unsigned int x, unsigned int y));
@@ -966,6 +967,13 @@
PRINT3("P%d %d %d\n", number, x, y);
}
+TERM_PUBLIC int
+X11_set_font(const char *fontname)
+{
+ PRINT1("F%s\n", fontname?fontname:"");
+ return( TRUE );
+}
+
TERM_PUBLIC void
X11_fillbox(int style, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
{
@@ -1082,7 +1090,7 @@
X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset,
X11_text, null_scale, X11_graphics, X11_move, X11_vector,
X11_linetype, X11_put_text, X11_text_angle,
- X11_justify_text, X11_point, do_arrow, set_font_null,
+ X11_justify_text, X11_point, do_arrow, X11_set_font,
X11_pointsize, TERM_CAN_MULTIPLOT,
X11_text /* suspend can use same routine */ , 0 /* resume */ ,
X11_fillbox, X11_linewidth
@@ -1104,7 +1112,7 @@
X11_VTIC, X11_HTIC, X11_options, X11_init, X11_reset,
X11_text, null_scale, X11_graphics, X11_move, X11_vector,
X11_linetype, X11_put_text, X11_text_angle,
- X11_justify_text, X11_point, do_arrow, set_font_null,
+ X11_justify_text, X11_point, do_arrow, X11_set_font,
X11_pointsize, TERM_CAN_MULTIPLOT,
X11_text /* suspend can use same routine */ , 0 /* resume */ ,
X11_fillbox, X11_linewidth
--- gnuplot/src/gplt_x11.c Fri Jul 26 16:20:22 2002
+++ gnuplot-eam/src/gplt_x11.c Sun Aug 18 17:54:44 2002
@@ -350,7 +350,7 @@
static char *pr_GetR __PROTO((XrmDatabase db, char *resource));
static void pr_color __PROTO((cmap_t * cmap_ptr));
static void pr_dashes __PROTO((void));
-static void pr_font __PROTO((void));
+static void pr_font __PROTO((char * fontname));
static void pr_geometry __PROTO((void));
static void pr_pointsize __PROTO((void));
static void pr_width __PROTO((void));
@@ -1453,6 +1453,15 @@
else if (*buffer == 'M')
sscanf(buffer, "M%4d%4d", &cx, &cy);
+ /* EAM - Aug 2002 change current font */
+ else if (*buffer == 'F') {
+ /* Strip out just the font name */
+ char *c = &(buffer[strlen(buffer)-1]);
+ while (*c <= ' ') *c-- = '\0';
+ pr_font(&buffer[1]);
+ XSetFont(dpy,gc,font->fid);
+ }
+
/* X11_put_text(x,y,str) - draw text */
else if (*buffer == 'T') {
sscanf(buffer, "T%4d%4d", &x, &y);
@@ -3435,7 +3444,7 @@
#endif /* PM3D */
pr_geometry();
- pr_font();
+ pr_font(NULL); /* set default font taken from Xresources */
pr_color(&cmap); /* set colors for default colormap */
pr_width();
pr_dashes();
@@ -3629,9 +3638,11 @@
*---------------------------------------------------------------------------*/
static void
-pr_font()
+pr_font( fontname )
+char *fontname;
{
- char *fontname = pr_GetR(db, ".font");
+ if (!fontname || !(*fontname))
+ fontname = pr_GetR(db, ".font");
if (!fontname)
fontname = FallbackFont;
@@ -3645,8 +3656,10 @@
gnuplot: can't load font '%s'\n\
gnuplot: no useable font - X11 aborted.\n", FallbackFont);
EXIT(1);
- }
+ } else
+ fontname = FallbackFont;
}
+ FPRINTF((stderr,"gnuplot_x11: set font %s\n",fontname));
vchar = font->ascent + font->descent;
}
[[[[ unsubscribe from info-gnuplot-beta via majordomo@dartmouth.edu ]]]]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic