/usr/share/doc/xviewg/examples/fonts/disp_fonts2.c is in xview-examples 3.2p1.4-28.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | /*
* disp_fonts2.c -- displays a collection of fonts in a canvas.
*/
#include <X11/X.h>
#include <X11/Xlib.h>
#include <xview/xview.h>
#include <xview/canvas.h>
#include <xview/font.h>
#include <xview/xv_xrect.h>
#ifdef SVR4
#define srandom( SEED ) srand( SEED )
#define random( SEED ) rand( SEED )
#endif
GC gc;
char *font_names[] = {
"courier", "courier-bold", "courier-16", "courier-oblique-19",
"lucidasans", "lucidasans-bold", "lucidasans-9", "lucidasans-italic",
"palatino-roman", "palatino-bold-14", "palatino-roman-7", "palatino-italic",
"times-bold", "times-bold-16", "times-roman", "times-roman-10", "times-italic-14",
"charter-black", "charter-black-13", "charter-black-italic",
"helvetica-20", "gillsans", "gillsans-bold", "gillsans-bolditalic",
"newcenturyschlbk-roman", "newcenturyschlbk-bold-15",
"rockwell", "rockwell-italic-16", "symbol", "symbol-16",
"symbol-19", "bookman-demi", "bookman-light-19",
"avantgarde-book", "avantgarde-demi", "avantgarde-demioblique"
};
Xv_Font fonts[sizeof(font_names)/ sizeof(char *)];
main(argc, argv)
int argc;
char *argv[];
{
Display *dpy;
Frame frame;
Canvas canvas;
XGCValues gcvalues;
Xv_Font font;
int i;
void my_repaint_proc();
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
frame = (Frame)xv_create(XV_NULL, FRAME,
FRAME_LABEL, argv[0],
FRAME_SHOW_FOOTER, TRUE,
NULL);
canvas = (Canvas)xv_create(frame, CANVAS,
XV_WIDTH, 500,
XV_HEIGHT, 300,
CANVAS_X_PAINT_WINDOW, TRUE,
CANVAS_REPAINT_PROC, my_repaint_proc,
NULL);
window_fit(frame);
dpy = (Display *)xv_get(frame, XV_DISPLAY);
for (i = 0; i < sizeof font_names / sizeof (char *); i++)
fonts[i] = (Xv_Font)xv_find(frame, FONT,
FONT_NAME, font_names[i],
NULL);
gcvalues.foreground = BlackPixel(dpy, DefaultScreen(dpy));
gcvalues.background = WhitePixel(dpy, DefaultScreen(dpy));
gcvalues.graphics_exposures = False;
gc = XCreateGC(dpy, RootWindow(dpy, DefaultScreen(dpy)),
GCForeground | GCBackground | GCGraphicsExposures, &gcvalues);
srandom(time(0));
xv_main_loop(frame);
}
void
my_repaint_proc(canvas, pw, dpy, xwin, xrects)
Canvas canvas;
Xv_Window pw;
Display *dpy;
Window xwin;
Xv_xrectlist *xrects;
{
int i, x, y;
int width = (int)xv_get(canvas, XV_WIDTH);
int height = (int)xv_get(canvas, XV_HEIGHT);
XFontStruct *fi;
x = -90;
y = 0;
for (i = 0; i < sizeof font_names / sizeof (char *); i++)
if (fonts[i]) {
if ( x+200 < width ) {
x += 100;
y += 20;
}
else {
x = 10;
y -= 15;
}
fi = (XFontStruct *)xv_get(fonts[i], FONT_INFO);
XSetFont(dpy, gc, fi->fid);
XDrawString(dpy, xwin, gc, x, y,
font_names[i], strlen(font_names[i]));
/* "Hello World", 11); */
}
}
|