From: ellson Date: Thu, 6 Mar 2008 23:30:52 +0000 (+0000) Subject: "dot -v" - get a bit more font resolution information from pango, before resorting... X-Git-Tag: LAST_LIBGRAPH~32^2~4557 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d8670ffc1ae8cfc507ac8e4af622db356ba54674;p=graphviz "dot -v" - get a bit more font resolution information from pango, before resorting to fontconfig --- diff --git a/lib/common/fontmetrics.c b/lib/common/fontmetrics.c index 021b905bd..5256b41c0 100644 --- a/lib/common/fontmetrics.c +++ b/lib/common/fontmetrics.c @@ -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; diff --git a/plugin/pango/gvtextlayout_pango.c b/plugin/pango/gvtextlayout_pango.c index 1628d00f1..1e1cd144c 100644 --- a/plugin/pango/gvtextlayout_pango.c +++ b/plugin/pango/gvtextlayout_pango.c @@ -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 *) ""; if (FcPatternGetString (fs->fonts[0], FC_STYLE, 0, &style) != FcResultMatch) style = (FcChar8 *) ""; - 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))