22 #ifdef HAVE_GD_FREETYPE
25 #define FONTSIZE_MUCH_TOO_SMALL 0.15
27 #define FONTSIZE_TOO_SMALL 1.5
29 #ifndef HAVE_GD_FONTCONFIG
35 char *gd_alternate_fontlist(
char *font)
42 len = strlen(font) + 1;
43 if (len > fontbufsz) {
46 fontbuf = malloc(fontbufsz);
48 fontbuf = realloc(fontbuf, fontbufsz);
52 strcpy(fontbuf, font);
53 if ((p = strchr(fontbuf,
'-')) || (p = strchr(fontbuf,
'_')))
60 fontlist =
"timesbd;Timesbd;TIMESBD;timesb;Timesb;TIMESB";
62 else if ((
strcasecmp(font,
"times-italic") == 0)
64 fontlist =
"timesi;Timesi;TIMESI";
66 else if ((
strcasecmp(font,
"timesnewroman") == 0)
70 fontlist =
"times;Times;TIMES";
74 fontlist =
"arialb;Arialb;ARIALB";
76 else if ((
strcasecmp(font,
"arial-italic") == 0)
78 fontlist =
"ariali;Ariali;ARIALI";
80 else if (
strcasecmp(fontbuf,
"helvetica") == 0)
81 fontlist =
"helvetica;Helvetica;HELVETICA;arial;Arial;ARIAL";
84 fontlist =
"arial;Arial;ARIAL";
87 fontlist =
"courier;Courier;COURIER;cour";
100 strcat(buf, comma ? " " : ", "); \
107 static char buf[1024];
118 static boolean gd_textlayout(
textspan_t * span,
char **fontpath)
120 char *err, *fontlist, *fontname;
123 gdFTStringExtra strex;
124 #ifdef HAVE_GD_FONTCONFIG
131 strex.fontpath =
NULL;
132 strex.flags = gdFTEX_RETURNFONTPATHNAME | gdFTEX_RESOLUTION;
135 if (strstr(fontname,
"/"))
136 strex.flags |= gdFTEX_FONTPATHNAME;
138 strex.flags |= gdFTEX_FONTCONFIG;
158 #ifdef HAVE_GD_FONTCONFIG
159 gdFTUseFontConfig(1);
166 fontlist = gd_alternate_fontlist(fontname);
169 err = gdImageStringFTEx(
NULL, brect, -1, fontlist,
170 fontsize, 0, 0, 0, span->
str, &strex);
178 *fontpath = strex.fontpath;
180 free (strex.fontpath);
182 if (span->
str && span->
str[0]) {
184 span->
size.
x = (double) (brect[4] - brect[0]);
188 span->
size.
y = (
int)(fontsize * 1.2);
200 #ifdef HAVE_GD_FREETYPE
201 {0,
"textlayout", 2, &gd_textlayout_engine,
NULL},
gvplugin_installed_t gvtextlayout_gd_types[]
char * gd_psfontResolve(PostscriptAlias *pa)
int agerr(agerrlevel_t level, const char *fmt,...)
#define FONTSIZE_TOO_SMALL
double yoffset_centerline
PostscriptAlias * postscript_alias
int strcasecmp(const char *s1, const char *s2)
void(* free_layout)(void *layout)
#define FONTSIZE_MUCH_TOO_SMALL