]> granicus.if.org Git - graphviz/commitdiff
recover from fonts that pango doesn't like on Darwin
authorellson <devnull@localhost>
Sun, 18 Jun 2006 13:39:23 +0000 (13:39 +0000)
committerellson <devnull@localhost>
Sun, 18 Jun 2006 13:39:23 +0000 (13:39 +0000)
lib/common/fontmetrics.c
plugin/pango/gvtextlayout_pango.c

index 1f9b35f1e631ceebd3424465ebdc2b2ba0c0c10a..a3514a1e10b831413c9a2ac8b411f25989ddd663 100644 (file)
@@ -168,7 +168,7 @@ pointf textsize(graph_t *g, textpara_t * para, char *fontname, double fontsize)
     para->fontname = fontname;
     para->fontsize = fontsize;
 
-    if (! gvtextlayout(GD_gvc(g), para, &fontpath))
+    if (! gvtextlayout(GD_gvc(g), para, &fontpath) || !fontpath)
        estimate_textlayout(g, para, &fontpath);
 
     if (Verbose) {
index d404f4f6e52547f14f0adc0a7ad0ee0d3a07aa2d..a5082287c1a2213dad9a67258808b06bb1636d93 100644 (file)
@@ -73,6 +73,16 @@ static void pango_textlayout(textpara_t * para, char **fontpath)
 #endif
 
     pango_layout_get_extents (layout, &ink_rect, &logical_rect);
+
+    /* if pango doesn't like the font then it sets width=0 but height = garbage */
+    if (logical_rect.width == 0) {
+       *fontpath = NULL;              /* indicate a problem */
+       logical_rect.height = 0;
+    }
+    else {
+       *fontpath = "[pango]";
+    }
+
     para->width = (double)logical_rect.width / PANGO_SCALE;
     para->height = (double)logical_rect.height / PANGO_SCALE;
 
@@ -90,8 +100,6 @@ static void pango_textlayout(textpara_t * para, char **fontpath)
 #endif
 
     pango_font_description_free (desc);
-
-    *fontpath = "[pango]";
 }
 
 static gvtextlayout_engine_t pango_textlayout_engine = {