From: ellson Date: Mon, 17 Jul 2006 18:03:47 +0000 (+0000) Subject: add some verbose information about pango+fontconfig font resolution X-Git-Tag: LAST_LIBGRAPH~32^2~6066 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34b5ba516901e608fa3d3d33314fe4144b71a7cc;p=graphviz add some verbose information about pango+fontconfig font resolution --- diff --git a/lib/gvc/gvplugin_textlayout.h b/lib/gvc/gvplugin_textlayout.h index b9a648ec9..25fcc8ba8 100644 --- a/lib/gvc/gvplugin_textlayout.h +++ b/lib/gvc/gvplugin_textlayout.h @@ -20,13 +20,14 @@ #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 diff --git a/lib/gvc/gvtextlayout.c b/lib/gvc/gvtextlayout.c index 86aa97e6f..a1a4292eb 100644 --- a/lib/gvc/gvtextlayout.c +++ b/lib/gvc/gvtextlayout.c @@ -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; diff --git a/plugin/gd/gvtextlayout_gd.c b/plugin/gd/gvtextlayout_gd.c index e6119bd6f..93ecb228b 100644 --- a/plugin/gd/gvtextlayout_gd.c +++ b/plugin/gd/gvtextlayout_gd.c @@ -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; diff --git a/plugin/pango/gvtextlayout_pango.c b/plugin/pango/gvtextlayout_pango.c index 1bc363499..6874e8db7 100644 --- a/plugin/pango/gvtextlayout_pango.c +++ b/plugin/pango/gvtextlayout_pango.c @@ -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