]> granicus.if.org Git - graphviz/commitdiff
"dot -v" - get a bit more font resolution information from pango, before resorting...
authorellson <devnull@localhost>
Thu, 6 Mar 2008 23:30:52 +0000 (23:30 +0000)
committerellson <devnull@localhost>
Thu, 6 Mar 2008 23:30:52 +0000 (23:30 +0000)
lib/common/fontmetrics.c
plugin/pango/gvtextlayout_pango.c

index 021b905bd555b452d9ab91fd64f84a8cbd547143..5256b41c00e3d45136da672724ecd275baa6feab 100644 (file)
@@ -211,8 +211,8 @@ pointf textsize(graph_t *g, textpara_t * para, char *fontname, double fontsize)
        estimate_textlayout(g, para, fp);
 
     if (fp)
-       fprintf(stderr, "%s: fontname \"%s\" resolved to: %s\n",
-                   GD_gvc(g)->common.cmdname, para->fontname, fontpath);
+       fprintf(stderr, "%s: font \"%s\" \"%g\" resolved to: %s\n",
+                   GD_gvc(g)->common.cmdname, para->fontname, para->fontsize, fontpath);
 
     size.x = para->width;
     size.y = para->height;
index 1628d00f175d9ab019b9281858968d6d87d82109..1e1cd144ce58538f8bb710c9fb3f0082e5ab9791 100644 (file)
@@ -85,18 +85,33 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
            fnt = fontname;
 
        desc = pango_font_description_from_string(fnt);
+        /* all text layout is done at a scale of 96ppi */
+        pango_font_description_set_size (desc, (gint)(para->fontsize * PANGO_SCALE));
 
         if (fontpath) {  /* -v support */
+           PangoFont *font;
+           PangoFontDescription *tdesc;
+           char *tfont;
+
+            font = pango_font_map_load_font(fontmap, context, desc);
+           tdesc = pango_font_describe(font);
+           tfont = pango_font_description_to_string(tdesc);
+           strcpy(buf, "\"");
+           strcat(buf, tfont);
+           strcat(buf, "\" ");
+           if (psfnt)
+               strcat(buf, "(PostScript) ");
+           else
+               strcat(buf, "(non-PS    ) ");
+
 #ifdef HAVE_FONTCONFIG
            FcPattern *pat, *match;
            FcFontSet *fs;
            FcResult result;
-           char *tfont;
     
             if (! FcInit())
                return FALSE;
     
-           tfont = pango_font_description_to_filename(desc);
            pat = FcNameParse((FcChar8 *) tfont);
            FcConfigSubstitute (0, pat, FcMatchPattern);
            FcDefaultSubstitute (pat);
@@ -105,7 +120,6 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
            if (match)
                FcFontSetAdd (fs, match);
            FcPatternDestroy (pat);
-           strcpy(buf,"");
            if (fs) {
                FcChar8 *family, *style, *file;
     
@@ -115,13 +129,6 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
                    family = (FcChar8 *) "<unknown font family>";
                if (FcPatternGetString (fs->fonts[0], FC_STYLE, 0, &style) != FcResultMatch)
                    style = (FcChar8 *) "<unknown font style>";
-               strcat(buf, "\"");
-               strcpy(buf, tfont);
-               strcat(buf, "\" ");
-               if (psfnt)
-                   strcat(buf, "(PostScript) ");
-               else
-                   strcat(buf, "(non-PS    ) ");
                strcat(buf, "\"");
                strcat(buf, (char *)family);
                strcat(buf, ", ");
@@ -129,16 +136,12 @@ static boolean pango_textlayout(textpara_t * para, char **fontpath)
                strcat(buf, "\" ");
                strcat(buf, (char *)file);
            }
-            *fontpath = buf;
-           g_free(tfont);
            FcFontSetDestroy(fs);
-#else
-           *fontpath = fnt;
 #endif
+            *fontpath = buf;
+           g_free(tfont);
         }
     }
-    /* all text layout is done at a scale of 96ppi */
-    pango_font_description_set_size (desc, (gint)(para->fontsize * PANGO_SCALE));
 
 #ifdef ENABLE_PANGO_MARKUP
     if (! pango_parse_markup (para->str, -1, 0, &attrs, &text, NULL, &error))