From: north Date: Thu, 1 Feb 2007 19:57:15 +0000 (+0000) Subject: Make SVG pass through raw font names, but allow -Gfontmangling attribute X-Git-Tag: LAST_LIBGRAPH~32^2~5686 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49cdff9a23cead87a742bce511d6ddc86589bada;p=graphviz Make SVG pass through raw font names, but allow -Gfontmangling attribute to enable Postscript name translation. (The job still isn't done, as the raw names aren't always right and should be mapped to the 7 standard SVG names, I guess.) --- diff --git a/lib/common/input.c b/lib/common/input.c index ca3d195be..61aeb8d03 100644 --- a/lib/common/input.c +++ b/lib/common/input.c @@ -626,6 +626,7 @@ void graph_init(graph_t * g, boolean use_rankdir) GD_ranksep(g) = POINTS(xf); GD_showboxes(g) = late_int(g, agfindattr(g, "showboxes"), 0, 0); + GD_fontmangling(g) = mapbool(agget(g,"fontmangling")); setRatio(g); GD_drawing(g)->filled = diff --git a/lib/common/types.h b/lib/common/types.h index 7fb9f83fb..006e2c956 100644 --- a/lib/common/types.h +++ b/lib/common/types.h @@ -354,6 +354,7 @@ extern "C" { boolean has_flat_edges; unsigned char showboxes; boolean cluster_was_collapsed; + boolean fontmangling; /* to override in SVG */ int nodesep, ranksep; node_t *ln, *rn; /* left, right nodes of bounding box */ @@ -419,6 +420,7 @@ extern "C" { #define GD_set_type(g) (g)->u.set_type #define GD_label_pos(g) (g)->u.label_pos #define GD_showboxes(g) (g)->u.showboxes +#define GD_fontmangling(g) (g)->u.fontmangling #define GD_spring(g) (g)->u.spring #define GD_sum_t(g) (g)->u.sum_t #define GD_t(g) (g)->u.t diff --git a/lib/gvc/gvcint.h b/lib/gvc/gvcint.h index eee5eca19..0acf27375 100644 --- a/lib/gvc/gvcint.h +++ b/lib/gvc/gvcint.h @@ -132,6 +132,9 @@ extern "C" { /* render defaults set from graph */ gvcolor_t bgcolor; /* background color */ + + /* whether to mangle font names (at least in SVG), usually false */ + boolean fontmangling; }; #ifdef __cplusplus diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index c56402b82..2882153fc 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -36,6 +36,7 @@ #include "const.h" #include "gvplugin_render.h" +#include "gvcint.h" #include "graph.h" typedef enum { FORMAT_SVG, FORMAT_SVGZ, } format_type; @@ -298,7 +299,12 @@ static void svg_textpara(GVJ_t * job, pointf p, textpara_t * para) } core_printf(job, " x=\"%g\" y=\"%g\"", p.x, -p.y); core_fputs(job, " style=\""); - if (para->postscript_alias) { + if (para->postscript_alias && GD_fontmangling(job->gvc->g)) { + /* i'm disabling this as the default because mapping "Times-Roman" + to "Nimbus Roman No9" does no good in the rendered SVG. in SVG + the only universal font families are Serif, Sans-Serif, Monospace, + Cursive and Fantasy but according to w3c, CSS can generally handle + the standard Postrscript names. */ core_printf(job, "font-family:%s;", para->postscript_alias->family); if (para->postscript_alias->weight) core_printf(job, "font-weight:%s;", para->postscript_alias->weight);