23#ifdef HAVE_GD_FREETYPE
26#define FONTSIZE_MUCH_TOO_SMALL 0.15
28#define FONTSIZE_TOO_SMALL 1.5
30#ifndef HAVE_GD_FONTCONFIG
36char *gd_alternate_fontlist(
const char *
font) {
41 if ((p = strchr(
font,
'-')) || (p = strchr(
font,
'_')))
44 if ((strcasecmp(
font,
"times-bold") == 0)
47 fontlist =
strview(
"timesbd;Timesbd;TIMESBD;timesb;Timesb;TIMESB",
'\0');
49 else if ((strcasecmp(
font,
"times-italic") == 0)
51 fontlist =
strview(
"timesi;Timesi;TIMESI",
'\0');
53 else if ((strcasecmp(
font,
"timesnewroman") == 0)
54 || (strcasecmp(
font,
"timesnew") == 0)
55 || (strcasecmp(
font,
"timesroman") == 0)
57 fontlist =
strview(
"times;Times;TIMES",
'\0');
59 else if ((strcasecmp(
font,
"arial-bold") == 0)
61 fontlist =
strview(
"arialb;Arialb;ARIALB",
'\0');
63 else if ((strcasecmp(
font,
"arial-italic") == 0)
65 fontlist =
strview(
"ariali;Ariali;ARIALI",
'\0');
68 fontlist =
strview(
"helvetica;Helvetica;HELVETICA;arial;Arial;ARIAL",
'\0');
71 fontlist =
strview(
"arial;Arial;ARIAL",
'\0');
74 fontlist =
strview(
"courier;Courier;COURIER;cour",
'\0');
87 strcat(buf, comma ? " " : ", "); \
94 static char buf[1024];
105static bool gd_textlayout(
textspan_t * span,
char **fontpath)
107 char *
err, *fontlist, *fontname;
110 gdFTStringExtra strex;
111#ifdef HAVE_GD_FONTCONFIG
118 strex.fontpath =
NULL;
119 strex.flags = gdFTEX_RETURNFONTPATHNAME | gdFTEX_RESOLUTION;
122 if (strchr(fontname,
'/'))
123 strex.flags |= gdFTEX_FONTPATHNAME;
125 strex.flags |= gdFTEX_FONTCONFIG;
145#ifdef HAVE_GD_FONTCONFIG
146 gdFTUseFontConfig(1);
153 fontlist = gd_alternate_fontlist(fontname);
156 err = gdImageStringFTEx(
NULL, brect, -1, fontlist,
157 fontsize, 0, 0, 0, span->
str, &strex);
158#ifndef HAVE_GD_FONTCONFIG
168 *fontpath = strex.fontpath;
170 free (strex.fontpath);
172 if (span->
str && span->
str[0]) {
174 span->
size.
x = (double) (brect[4] - brect[0]);
188#ifdef HAVE_GD_FREETYPE
189 {0,
"textlayout", 2, &gd_textlayout_engine,
NULL},
#define FONTSIZE_MUCH_TOO_SMALL
#define FONTSIZE_TOO_SMALL
char * gd_psfontResolve(PostscriptAlias *pa)
void agerrorf(const char *fmt,...)
gvplugin_installed_t gvtextlayout_gd_types[]
platform abstraction for case-insensitive string functions
a non-owning string reference
size_t size
extent of the string in bytes
PostscriptAlias * postscript_alias
double yoffset_centerline
void(* free_layout)(void *layout)
Non-owning string references.
static char * strview_str(strview_t source)
make a heap-allocated string from this string view
static strview_t strview(const char *referent, char terminator)
create a string reference
static bool strview_case_str_eq(strview_t a, const char *b)
compare a string reference to a string for case insensitive equality