]> granicus.if.org Git - graphviz/commitdiff
hack to strip ".ttf" from "FreeSans.ttf" in an attempt to find a better font for...
authorellson <devnull@localhost>
Fri, 25 Jan 2008 13:49:19 +0000 (13:49 +0000)
committerellson <devnull@localhost>
Fri, 25 Jan 2008 13:49:19 +0000 (13:49 +0000)
plugin/pango/gvtextlayout_pango.c

index 899aa1902a0c2139d29a588fbfd0032c9c169593..a1575825a757895038ecd2c1ac6e8b2f40f8916d 100644 (file)
@@ -58,7 +58,7 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
     PangoAttrList *attrs;
     GError *error = NULL;
 #endif
-    char *text;
+    char *text, *tfnt, *pos;
     double textlayout_scale;
 
     if (!context) {
@@ -84,7 +84,12 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
        else
            fnt = fontname;
 
-       desc = pango_font_description_from_string(fnt);
+       /* suppress any extents - like in FreeSans.ttf (doxygen backwards compat) */
+       tfnt = strdup(fnt);
+       if ((pos = strrchr(tfnt, '.')))
+           *pos = '\0';
+
+       desc = pango_font_description_from_string(tfnt);
 
         if (fontpath) {  /* -v support */
 #ifdef HAVE_FONTCONFIG
@@ -92,10 +97,12 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
            FcFontSet *fs;
            FcResult result;
     
-            if (! FcInit())
+            if (! FcInit()) {
+               free(tfnt);
                return FALSE;
+           }
     
-           pat = FcNameParse((FcChar8 *) fnt);
+           pat = FcNameParse((FcChar8 *) tfnt);
            FcConfigSubstitute (0, pat, FcMatchPattern);
            FcDefaultSubstitute (pat);
            fs = FcFontSetCreate();
@@ -126,6 +133,7 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
            *fontpath = fnt;
 #endif
         }
+       free(tfnt);
     }
     /* all text layout is done at a scale of 96ppi */
     pango_font_description_set_size (desc, (gint)(para->fontsize * PANGO_SCALE));