29 #ifndef HAVE_STRCASESTR
34 const char *endp, *sp, *pp;
35 if (!(p0 = *pat))
return (
char*)
str;
36 plen = strlen (pat++);
38 if (slen < plen)
return NULL;
39 endp = str + slen - plen;
42 while ((str <= endp) && (p0 != toupper(*str))) str++;
43 if (str > endp)
return NULL;
46 while ((pc = *pp++) && (toupper(pc) == toupper(*sp))) sp++;
48 return (
char*)(str-1);
55 #include <pango/pangocairo.h>
62 #define FNT_CONDENSED 1<<2
64 #define FNT_EXTRALIGHT 1<<4
65 #define FNT_ITALIC 1<<5
66 #define FNT_LIGHT 1<<6
67 #define FNT_MEDIUM 1<<7
68 #define FNT_OBLIQUE 1<<8
69 #define FNT_REGULAR 1<<9
70 #define FNT_ROMAN 1<<9
72 #define PS_AVANTGARDE "AvantGarde"
73 #define PS_BOOKMAN "Bookman"
74 #define PS_COURIER "Courier"
75 #define PS_HELVETICA SAN_5
76 #define PS_NEWCENTURYSCHLBK "NewCenturySchlbk"
77 #define PS_PALATINO "Palatino"
78 #define PS_SYMBOL "Symbol"
79 #define PS_TIMES SER_3
80 #define PS_CHANCERY "ZapfChancery"
81 #define PS_DINGBATS "ZapfDingbats"
83 #define FNT_BOLD_ST "BOLD"
84 #define FNT_BOOK_ST "BOOK"
85 #define FNT_CONDENSED_ST "CONDENSED"
86 #define FNT_DEMI_ST "DEMI"
87 #define FNT_EXTRALIGHT_ST "EXTRALIGHT"
88 #define FNT_ITALIC_ST "ITALIC"
89 #define FNT_LIGHT_ST "LIGHT"
90 #define FNT_MEDIUM_ST "MEDIUM"
91 #define FNT_OBLIQUE_ST "OBLIQUE"
92 #define FNT_REGULAR_ST "REGULAR"
93 #define FNT_ROMAN_ST "ROMAN"
96 #define SAN_1 "URW Gothic L"
97 #define SAN_2 "Charcoal"
98 #define SAN_3 "Nimbus Sans L"
99 #define SAN_4 "Verdana"
100 #define SAN_5 "Helvetica"
101 #define SAN_6 "Bitstream Vera Sans"
102 #define SAN_7 "DejaVu Sans"
103 #define SAN_8 "Liberation Sans"
104 #define SAN_9 "Luxi Sans"
105 #define SAN_10 "FreeSans"
106 #define SAN_11 "Arial"
108 #define SER_0 "serif"
109 #define SER_1 "URW Bookman L"
110 #define SER_2 "Times New Roman"
111 #define SER_3 "Times"
112 #define SER_4 "Nimbus Roman No9 L"
113 #define SER_5 "Bitstream Vera Serif"
114 #define SER_6 "DejaVu Serif"
115 #define SER_7 "Liberation Serif"
116 #define SER_8 "Luxi Serif"
117 #define SER_9 "FreeSerif"
118 #define SER_10 "Century Schoolbook L"
119 #define SER_11 "Charcoal"
120 #define SER_12 "Georgia"
121 #define SER_13 "URW Palladio L"
122 #define SER_14 "Norasi"
123 #define SER_15 "Rekha"
124 #define SER_16 "URW Chancery L"
126 #define MON_0 "monospace"
127 #define MON_1 "Nimbus Mono L"
128 #define MON_2 "Inconsolata"
129 #define MON_3 "Courier New"
130 #define MON_4 "Bitstream Vera Sans Mono"
131 #define MON_5 "DejaVu Sans Mono"
132 #define MON_6 "Liberation Mono"
133 #define MON_7 "Luxi Mono"
134 #define MON_8 "FreeMono"
136 #define SYM_0 "fantasy"
137 #define SYM_1 "Impact"
138 #define SYM_2 "Copperplate Gothic Std"
139 #define SYM_3 "Cooper Std"
140 #define SYM_4 "Bauhaus Std"
142 #define DING_0 "fantasy"
143 #define DING_1 "Dingbats"
144 #define DING_2 "Impact"
145 #define DING_3 "Copperplate Gothic Std"
146 #define DING_4 "Cooper Std"
147 #define DING_5 "Bauhaus Std"
154 static face_t facelist[] = {
167 #define FACELIST_SZ (sizeof(facelist)/sizeof(face_t))
173 static const char *PS_AVANT_E[] = {
176 #define PS_AVANT_E_SZ (sizeof(PS_AVANT_E) / sizeof(char *))
178 static const char *PS_BOOKMAN_E[] = {
181 #define PS_BOOKMAN_E_SZ (sizeof(PS_BOOKMAN_E) / sizeof(char *))
183 static const char *PS_COURIER_E[] = {
186 #define PS_COURIER_E_SZ (sizeof(PS_COURIER_E) / sizeof(char *))
188 static const char *PS_HELVETICA_E[] = {
191 #define PS_HELVETICA_E_SZ (sizeof(PS_HELVETICA_E) / sizeof(char *))
193 static const char *PS_NEWCENT_E[] = {
196 #define PS_NEWCENT_E_SZ (sizeof(PS_NEWCENT_E) / sizeof(char *))
198 static const char *PS_PALATINO_E[] = {
199 SER_13,
SER_2,
SER_3,
SER_4,
SER_14,
SER_15,
SER_5,
SER_6,
SER_7,
SER_8,
SER_9
201 #define PS_PALATINO_E_SZ (sizeof(PS_PALATINO_E) / sizeof(char *))
203 static const char *PS_TIMES_E[] = {
206 #define PS_TIMES_E_SZ (sizeof(PS_TIMES_E) / sizeof(char *))
209 #define PS_SYMBOL_E_SZ (sizeof(PS_SYMBOL_E) / sizeof(char *))
211 static const char *PS_CHANCERY_E[] = {
214 #define PS_CHANCERY_E_SZ (sizeof(PS_CHANCERY_E) / sizeof(char *))
217 #define PS_DINGBATS_E_SZ (sizeof(PS_DINGBATS_E) / sizeof(char *))
239 #define GV_FONT_LIST_SIZE (sizeof(gv_ps_fontdefs)/sizeof(fontdef_t))
247 #define NEW(t) (t*)malloc(sizeof(t))
248 #define N_NEW(n,t) (t*)malloc((n)*sizeof(t))
260 if (gv_af_p[i].fontname)
261 free(gv_af_p[i].fontname);
266 static int get_faces(PangoFontFamily * family)
268 PangoFontFace **faces;
274 pango_font_family_list_faces(family, &faces, &n_faces);
275 for (i = 0; i < n_faces; i++) {
277 name = pango_font_face_get_face_name(face);
283 availfaces |= facelist[j].
flag;
300 if ((gv_af_p[j].faces == 0) || (gv_af_p[j].fontname ==
NULL)) {
301 fprintf (stderr,
"ps font = %s not available\n", gv_ps_fontdefs[j].fontname);
304 fprintf (stderr,
"ps font = %s available %d font = %s\n",
305 gv_ps_fontdefs[j].fontname, gv_af_p[j].faces, gv_af_p[j].fontname);
306 faces = gv_af_p[j].
faces;
308 if (faces & facelist[i].flag)
309 fprintf (stderr,
"\t%s\n", facelist[i].name);
316 static char *get_avail_faces(
int faces,
agxbuf* xb)
320 if (faces & facelist[i].flag) {
321 agxbput (xb, facelist[i].name);
334 static availfont_t *gv_get_ps_fontlist(PangoFontMap * fontmap)
336 PangoFontFamily **families;
337 PangoFontFamily *family;
340 int i, j, k, array_sz, availfaces;
346 pango_font_map_list_families(fontmap, &families, &n_families);
355 gv_ps_fontdef = gv_ps_fontdefs+j;
360 for (i = 0; i < n_families; i++) {
361 family = families[i];
362 name = pango_font_family_get_name(family);
365 family_name = strdup(name);
366 availfaces = get_faces(family);
374 array_sz = gv_ps_fontdef->
eq_sz;
375 for (k = 0; k < array_sz; k++) {
376 for (i = 0; i < n_families; i++) {
377 family = families[i];
378 name = pango_font_family_get_name(family);
380 family_name = strdup(name);
381 availfaces = get_faces(family);
392 for (i = 0; i < n_families; i++) {
393 family = families[i];
394 name = pango_font_family_get_name(family);
396 family_name = strdup(name);
397 availfaces = get_faces(family);
404 if (family_name && availfaces) {
406 gv_afs->
faces = availfaces;
414 display_available_fonts(gv_af_p);
420 static void copyUpper (
agxbuf* xb,
char*
s)
445 agxbput(xb2, gv_af_p[i].fontname);
447 avail_faces = get_avail_faces(gv_af_p[i].faces, xb);
451 copyUpper(xb2, ps_alias->
weight);
453 }
else if (
strcasestr(avail_faces,
"REGULAR")) {
456 }
else if (strstr(avail_faces,
"ROMAN")) {
463 copyUpper(xb2, ps_alias->
stretch);
466 if (ps_alias->
style) {
469 copyUpper(xb2, ps_alias->
style);
495 for (j = 0; j < sz; j++) {
498 fprintf (stderr,
" [%d] %s => <Not available>\n", j, gv_fmap[j].gv_ps_fontname);
500 fprintf (stderr,
" [%d] %s => \"%s\"\n", j, gv_fmap[j].gv_ps_fontname, font);
511 int j, ps_fontnames_sz =
sizeof(postscript_alias) /
sizeof(
PostscriptAlias);
515 unsigned char buf[BUFSIZ];
516 unsigned char buf2[BUFSIZ];
520 gv_af_p = gv_get_ps_fontlist(fontmap);
522 for (j = 0; j < ps_fontnames_sz; j++) {
523 ps_alias = &postscript_alias[j];
525 gv_fmap[ps_alias->
xfig_code].
gv_font = gv_get_font(gv_af_p, ps_alias, &xb, &xb2);
527 gv_flist_free_af(gv_af_p);
532 fprintf(stderr,
"Verbose %d\n",
Verbose);
533 printFontMap (gv_fmap, ps_fontnames_sz);
545 PangoFontMap *fontmap;
549 fontlist =
N_NEW(GV_FONT_LIST_SIZE,
char *);
550 fontmap = pango_cairo_font_map_new();
551 gv_af_p = gv_get_ps_fontlist(fontmap);
552 g_object_unref(fontmap);
557 if ((gv_af_p[j].faces == 0) || (gv_af_p[j].
fontname ==
NULL)) {
560 *(fontlist + i++) = strdup(gv_af_p[j].fontname);
564 free(*(fontlist + j));
567 gv_flist_free_af(gv_af_p);
size_t agxbput(agxbuf *xb, const char *s)
#define FNT_EXTRALIGHT_ST
char * strcasestr(const char *str, const char *pat)
void agxbinit(agxbuf *xb, unsigned int hint, unsigned char *init)
#define GV_FONT_LIST_SIZE
gv_font_map * get_font_mapping(PangoFontMap *pfm)
void get_font_list(char **fonts[], int *cnt)
#define PS_NEWCENTURYSCHLBK
EXTERN unsigned char Verbose
int strcasecmp(const char *s1, const char *s2)
void agxbfree(agxbuf *xb)
#define PS_HELVETICA_E_SZ