]> granicus.if.org Git - graphviz/commitdiff
add some verbose information about pango+fontconfig font resolution
authorellson <devnull@localhost>
Mon, 17 Jul 2006 18:03:47 +0000 (18:03 +0000)
committerellson <devnull@localhost>
Mon, 17 Jul 2006 18:03:47 +0000 (18:03 +0000)
lib/gvc/gvplugin_textlayout.h
lib/gvc/gvtextlayout.c
plugin/gd/gvtextlayout_gd.c
plugin/pango/gvtextlayout_pango.c

index b9a648ec99ff65b659a6c0dbeef09824f9f0dbd4..25fcc8ba850c48fcc351cd3a4d5176a1f1e8fba5 100644 (file)
 #include "types.h"
 #include "gvplugin.h"
 #include "gvcjob.h"
+#include "gvcommon.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
     struct gvtextlayout_engine_s {
-       void (*textlayout) (textpara_t *para, char** fontpath);
+       void (*textlayout) (GVCOMMON_t *common, textpara_t *para, char** fontpath);
     };
 
 #ifdef __cplusplus
index 86aa97e6ff52ed5867ca61378da1a52b910c7edb..a1a4292eb1892f6131c9f20be63f20ed93a7cf3f 100644 (file)
@@ -46,7 +46,7 @@ bool gvtextlayout(GVC_t *gvc, textpara_t *para, char **fontpath)
     gvtextlayout_engine_t *gvte = gvc->textlayout.engine;
 
     if (gvte && gvte->textlayout) {
-       gvte->textlayout(para, fontpath);
+       gvte->textlayout(&(gvc->common), para, fontpath);
        return TRUE;
     }
     return FALSE;
index e6119bd6f50b6e011c573e53e9a95b19da1d851f..93ecb228b769c39cd6b5b6cf5e4fee710e6a1011 100644 (file)
@@ -33,7 +33,7 @@
 /* fontsize at which text is rendered by a simple line */
 #define FONTSIZE_TOO_SMALL 1.5
 
-static void gd_textlayout(textpara_t * para, char **fontpath)
+static void gd_textlayout(GVCOMMON_t *common, textpara_t * para, char **fontpath)
 {
     static char *fntpath;
     char *err;
index 1bc363499f26177c889cf1bfbef80cff9f3031b2..6874e8db70dfe1212a15b0a26cbe42566d87e719 100644 (file)
@@ -94,7 +94,7 @@ static void pango_free_layout (void *layout)
     g_object_unref((PangoLayout*)layout);
 }
 
-static void pango_textlayout(textpara_t * para, char **fontpath)
+static void pango_textlayout(GVCOMMON_t *common, textpara_t * para, char **fontpath)
 {
     static PangoFontMap *fontmap;
     static PangoContext *context;
@@ -109,7 +109,7 @@ static void pango_textlayout(textpara_t * para, char **fontpath)
     PangoAttrList *attrs;
     GError *error = NULL;
 #endif
-    char *text, *psfont;
+    char *text, *fontreq, *family;
 
     if (!fontmap)
         fontmap = pango_cairo_font_map_get_default();
@@ -117,10 +117,26 @@ static void pango_textlayout(textpara_t * para, char **fontpath)
     if (!context)
         context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP(fontmap));
 
-    if ((psfont = find_postscript_font(para->fontname)))
-        desc = pango_font_description_from_string(psfont);
-    else
-        desc = pango_font_description_from_string(para->fontname);
+    /* try to find a match for a PostScript font - or just get best available match */
+    if (common->verbose)
+       fprintf(stderr, "Font: \"%s\"", para->fontname);
+
+    if ((fontreq = find_postscript_font(para->fontname))) {
+        if (common->verbose)
+           fprintf(stderr, " (ps) translated to: \"%s\"", fontreq);
+    }
+    else {
+       fontreq = para->fontname;
+    }
+    desc = pango_font_description_from_string(fontreq);
+    if (common->verbose) {
+       family = pango_font_description_get_family (desc);
+       if (strcmp(family, fontreq) == 0)
+           fprintf(stderr, " resolved.\n");
+       else
+            fprintf(stderr, " resolved to: \"%s\"\n", family);
+    }
+
     pango_font_description_set_size (desc, (gint)(para->fontsize * PANGO_SCALE));
 
 #ifdef ENABLE_PANGO_MARKUP