Get rid of some crud from the gd plugin. Without freetype+fontconfig revert to the...
authorellson <devnull@localhost>
Tue, 30 May 2006 00:42:42 +0000 (00:42 +0000)
committerellson <devnull@localhost>
Tue, 30 May 2006 00:42:42 +0000 (00:42 +0000)
plugin/gd/gvrender_gd.c
plugin/gd/gvtextlayout_gd.c

index c22fee06c8f21e5709e1aeb3b399ffb74ca79d9b..409406328679850caba24d0b1962cf6eeb48fdd1 100644 (file)
@@ -277,67 +277,6 @@ static void gdgen_end_graph(GVJ_t * job)
     }
 }
 
-/* sometimes fonts are stored under a different name */
-char *gdgen_alternate_fontlist(char *font)
-{
-#ifdef HAVE_GD_FONTCONFIG
-    return font;
-#else
-    static char *fontbuf;
-    static int fontbufsz;
-    char *p, *fontlist;
-    int len;
-
-    len = strlen(font) + 1;
-    if (len > fontbufsz) {
-       fontbufsz = 2 * len;
-       if (fontbuf)
-           fontbuf = malloc(fontbufsz);
-       else
-           fontbuf = realloc(fontbuf, fontbufsz);
-    }
-
-    /* fontbuf to contain font without style descriptions like -Roman or -Italic */
-    strcpy(fontbuf, font);
-    if ((p = strchr(fontbuf, '-')) || (p = strchr(fontbuf, '_')))
-       *p = 0;
-
-    fontlist = fontbuf;
-    if ((strcasecmp(font, "times-bold") == 0)
-       || (strcasecmp(fontbuf, "timesb") == 0))
-       fontlist = "timesb;Timesb;TIMESB";
-
-    else if ((strcasecmp(font, "times-italic") == 0)
-            || (strcasecmp(fontbuf, "timesi") == 0))
-       fontlist = "timesi;Timesi;TIMESI";
-
-    else if ((strcasecmp(font, "timesnewroman") == 0)
-            || (strcasecmp(font, "timesnew") == 0)
-            || (strcasecmp(font, "timesroman") == 0)
-            || (strcasecmp(fontbuf, "times") == 0))
-       fontlist = "times;Times;TIMES";
-
-    else if ((strcasecmp(font, "arial-bold") == 0)
-            || (strcasecmp(fontbuf, "arialb") == 0))
-       fontlist = "arialb;Alialb;ARIALB";
-
-    else if ((strcasecmp(font, "arial-italic") == 0)
-            || (strcasecmp(fontbuf, "ariali") == 0))
-       fontlist = "ariali;Aliali;ARIALI";
-
-    else if (strcasecmp(fontbuf, "helvetica") == 0)
-       fontlist = "helvetica;Helvetica;HELVETICA;arial;Arial;ARIAL";
-
-    else if (strcasecmp(fontbuf, "arial") == 0)
-       fontlist = "arial;Arial;ARIAL";
-
-    else if (strcasecmp(fontbuf, "courier") == 0)
-       fontlist = "courier;Courier;COURIER;cour";
-
-    return fontlist;
-#endif                         /* HAVE_GD_FONTCONFIG */
-}
-
 void gdgen_missingfont(char *err, char *fontreq)
 {
     static char *lastmissing = 0;
@@ -346,7 +285,7 @@ void gdgen_missingfont(char *err, char *fontreq)
     if (n_errors >= 20)
        return;
     if ((lastmissing == 0) || (strcmp(lastmissing, fontreq))) {
-#if HAVE_GD_FONTCONFIG
+#if defined(HAVE_LIBFONTCONFIG) && defined(HAVE_GD_FONTCONFIG)
 #if 0
 /* FIXME - error function */
        agerr(AGERR, "%s : %s\n", err, fontreq);
@@ -384,7 +323,7 @@ static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
     double parawidth = para->width * job->compscale.x;
     double fontsz = style->fontsz;
     gdFTStringExtra strex;
-#ifdef HAVE_GD_FREETYPE
+#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
     char *err;
     int brect[8];
 #endif
@@ -400,7 +339,7 @@ static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
     else
        strex.flags |= gdFTEX_FONTCONFIG;
 
-    fontlist = gdgen_alternate_fontlist(style->fontfam);
+    fontlist = (char*)(para->layout);
 
     switch (para->just) {
     case 'l':
@@ -435,7 +374,7 @@ static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
                    ROUND(ep.x), ROUND(ep.y),
                    style->pencolor.u.index);
     } else {
-#ifdef HAVE_GD_FREETYPE
+#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
        err = gdImageStringFTEx(im, brect, style->pencolor.u.index,
                                fontlist, fontsz, job->rotation ? (PI / 2) : 0,
                                ROUND(mp.x), ROUND(mp.y), str, &strex);
@@ -481,7 +420,7 @@ static void gdgen_textpara(GVJ_t * job, pointf p, textpara_t * para)
                              (unsigned char *) str,
                              style->pencolor.u.index);
            }
-#ifdef HAVE_GD_FREETYPE
+#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
        }
 #endif
     }
index 58ff1a4775c5e4f81ff556ff1a96519f4a8ee679..63ba7c501ccc7c647fa0bf0e5dce98302676c725 100644 (file)
 #ifdef HAVE_LIBGD
 #include "gd.h"
 
-#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
+#if defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE) && defined(HAVE_LIBFONTCONFIG) && defined(HAVE_GD_FONTCONFIG)
 
 /* fontsize at which text is omitted entirely */
 #define FONTSIZE_MUCH_TOO_SMALL 0.15
 /* fontsize at which text is rendered by a simple line */
 #define FONTSIZE_TOO_SMALL 1.5
 
-/* sometimes fonts are stored under a different name */
-char *gd_alternate_fontlist(char *font)
-{
-#ifdef HAVE_GD_FONTCONFIG
-    return font;
-#else
-    static char *fontbuf;
-    static int fontbufsz;
-    char *p, *fontlist;
-    int len;
-
-    len = strlen(font) + 1;
-    if (len > fontbufsz) {
-       fontbufsz = 2 * len;
-       if (fontbuf)
-           fontbuf = malloc(fontbufsz);
-       else
-           fontbuf = realloc(fontbuf, fontbufsz);
-    }
-
-    /* fontbuf to contain font without style descriptions like -Roman or -Italic */
-    strcpy(fontbuf, font);
-    if ((p = strchr(fontbuf, '-')) || (p = strchr(fontbuf, '_')))
-       *p = 0;
-
-    fontlist = fontbuf;
-    if ((strcasecmp(font, "times-bold") == 0)
-       || (strcasecmp(fontbuf, "timesbd") == 0)
-       || (strcasecmp(fontbuf, "timesb") == 0))
-       fontlist = "timesbd;Timesbd;TIMESBD;timesb;Timesb;TIMESB";
-
-    else if ((strcasecmp(font, "times-italic") == 0)
-            || (strcasecmp(fontbuf, "timesi") == 0))
-       fontlist = "timesi;Timesi;TIMESI";
-
-    else if ((strcasecmp(font, "timesnewroman") == 0)
-            || (strcasecmp(font, "timesnew") == 0)
-            || (strcasecmp(font, "timesroman") == 0)
-            || (strcasecmp(fontbuf, "times") == 0))
-       fontlist = "times;Times;TIMES";
-
-    else if ((strcasecmp(font, "arial-bold") == 0)
-            || (strcasecmp(fontbuf, "arialb") == 0))
-       fontlist = "arialb;Alialb;ARIALB";
-
-    else if ((strcasecmp(font, "arial-italic") == 0)
-            || (strcasecmp(fontbuf, "ariali") == 0))
-       fontlist = "ariali;Aliali;ARIALI";
-
-    else if (strcasecmp(fontbuf, "helvetica") == 0)
-       fontlist = "helvetica;Helvetica;HELVETICA;arial;Arial;ARIAL";
-
-    else if (strcasecmp(fontbuf, "arial") == 0)
-       fontlist = "arial;Arial;ARIAL";
-
-    else if (strcasecmp(fontbuf, "courier") == 0)
-       fontlist = "courier;Courier;COURIER;cour";
-
-    return fontlist;
-#endif                         /* HAVE_GD_FONTCONFIG */
-}
-
 void textlayout(textpara_t * para, char *fontname, double fontsize, char **fontpath)
 {
     static char *fntpath;
-    char *fontlist, *err;
+    char *err;
     int brect[8];
     gdFTStringExtra strex;
 
@@ -116,12 +54,10 @@ void textlayout(textpara_t * para, char *fontname, double fontsize, char **fontp
     para->width = 0.0;
     para->xshow = NULL;
 
-    fontlist = gd_alternate_fontlist(fontname);
-    para->layout = (void*)fontlist;
-    para->free_layout = NULL; /* no need to free fontlist (??) */
-
+    para->layout = (void*)fontname;
+    para->free_layout = NULL; /* no need to free fontname */
 
-    if (fontlist) {
+    if (fontname) {
        if (fontsize <= FONTSIZE_MUCH_TOO_SMALL) {
            /* OK, but ignore text entirely */
            return;
@@ -131,7 +67,7 @@ void textlayout(textpara_t * para, char *fontname, double fontsize, char **fontp
            fontsize = FONTSIZE_TOO_SMALL;
        }
        /* call gdImageStringFT with null *im to get brect and to set font cache */
-       err = gdImageStringFTEx(NULL, brect, -1, fontlist,
+       err = gdImageStringFTEx(NULL, brect, -1, fontname,
                                fontsize, 0, 0, 0, para->str, &strex);
 
        if (err) {
@@ -164,7 +100,7 @@ gvtextlayout_engine_t textlayout_engine = {
 #endif
 
 gvplugin_installed_t gvtextlayout_gd_types[] = {
-#if defined(HAVE_LIBGD) && defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE)
+#if defined(HAVE_LIBGD) && defined(HAVE_LIBFREETYPE) && defined(HAVE_GD_FREETYPE) && defined(HAVE_LIBFONTCONFIG) && defined(HAVE_GD_FONTCONFIG)
     {0, "textlayout", 2, &textlayout_engine, NULL},
 #endif
     {0, NULL, 0, NULL, NULL}