From 3e8ea3eefe66fcb8d69545513cbdfc99d1914b27 Mon Sep 17 00:00:00 2001 From: ellson Date: Fri, 11 Aug 2006 13:18:51 +0000 Subject: [PATCH] provide default page width/height from renderer to fix problem exhibited by graphs/directed/switch.dot when -Gcenter -Tpng --- lib/common/const.h | 3 --- lib/common/emit.c | 15 +++++++++++---- lib/gvc/gvcjob.h | 2 +- plugin/core/gvrender_core_dot.c | 2 +- plugin/core/gvrender_core_fig.c | 2 +- plugin/core/gvrender_core_map.c | 4 ++-- plugin/core/gvrender_core_ps.c | 2 +- plugin/core/gvrender_core_svg.c | 2 +- plugin/gd/gvrender_gd.c | 4 ++-- plugin/gd/gvrender_gd_vrml.c | 2 +- plugin/pango/gvrender_pango.c | 8 ++++---- 11 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/common/const.h b/lib/common/const.h index c0cb40b10..019e6800c 100644 --- a/lib/common/const.h +++ b/lib/common/const.h @@ -86,9 +86,6 @@ #define DEFAULT_RANKSEP 0.5 #define MIN_RANKSEP 0.02 -/* default page size in points - including margins = 8.5in x 11in */ -#define DEFAULT_PAGEWD 612 -#define DEFAULT_PAGEHT 792 /* default margin for paged formats such as PostScript - in points = 0.5in */ #define DEFAULT_PRINT_MARGIN 36 /* default margin for embedded formats such as PNG - in points */ diff --git a/lib/common/emit.c b/lib/common/emit.c index be5afd36c..8aefe7d0d 100644 --- a/lib/common/emit.c +++ b/lib/common/emit.c @@ -610,10 +610,17 @@ static void init_job_pagination(GVJ_t * job, graph_t *g) imageSize.x = MIN(imageSize.x, pageSize.x); imageSize.y = MIN(imageSize.y, pageSize.y); } else { - /* page not set by user, assume default when centering, - but allow infinite page for any other interpretation */ - pageSize.x = DEFAULT_PAGEWD - 2 * margin.x; - pageSize.y = DEFAULT_PAGEHT - 2 * margin.y; + /* page not set by user, use default from renderer */ + if (job->render.features) { + pageSize.x = job->render.features->default_pagesize.x - 2*margin.x; + if (pageSize.x < 0.) + pageSize.x = 0.; + pageSize.y = job->render.features->default_pagesize.y - 2*margin.y; + if (pageSize.y < 0.) + pageSize.y = 0.; + } + else + pageSize.x = pageSize.y = 0.; job->pagesArraySize.x = job->pagesArraySize.y = job->numPages = 1; } diff --git a/lib/gvc/gvcjob.h b/lib/gvc/gvcjob.h index 1cd30963a..2748c0765 100644 --- a/lib/gvc/gvcjob.h +++ b/lib/gvc/gvcjob.h @@ -68,7 +68,7 @@ extern "C" { int flags; double default_margin; /* points */ double default_pad; /* graph units */ - point default_size; /* default height, width - device units */ + pointf default_pagesize;/* default page width, height - points */ pointf default_dpi; char **knowncolors; int sz_knowncolors; diff --git a/plugin/core/gvrender_core_dot.c b/plugin/core/gvrender_core_dot.c index f96395b7a..478398d29 100644 --- a/plugin/core/gvrender_core_dot.c +++ b/plugin/core/gvrender_core_dot.c @@ -328,7 +328,7 @@ gvrender_features_t dot_features = { 0, /* flags */ 0., /* default margin - points */ 0., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {72.,72.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ diff --git a/plugin/core/gvrender_core_fig.c b/plugin/core/gvrender_core_fig.c index aa9e2a408..faad29793 100644 --- a/plugin/core/gvrender_core_fig.c +++ b/plugin/core/gvrender_core_fig.c @@ -516,7 +516,7 @@ gvrender_features_t fig_features = { | GVRENDER_Y_GOES_DOWN, /* flags */ DEFAULT_EMBED_MARGIN, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {1440.,1440.}, /* default dpi */ /* FIXME - this default dpi is a very strange number!!! * It was picked to make .png usershapes the right size on my screen. diff --git a/plugin/core/gvrender_core_map.c b/plugin/core/gvrender_core_map.c index b496a61aa..4ea7ac057 100644 --- a/plugin/core/gvrender_core_map.c +++ b/plugin/core/gvrender_core_map.c @@ -286,7 +286,7 @@ static gvrender_features_t map_features = { | GVRENDER_DOES_MAP_POLYGON, 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ @@ -304,7 +304,7 @@ static gvrender_features_t map_features_nopoly = { | GVRENDER_DOES_MAP_RECTANGLE, 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ diff --git a/plugin/core/gvrender_core_ps.c b/plugin/core/gvrender_core_ps.c index 38a9ddb5a..231cca7b0 100644 --- a/plugin/core/gvrender_core_ps.c +++ b/plugin/core/gvrender_core_ps.c @@ -497,7 +497,7 @@ static gvrender_features_t psgen_features = { | GVRENDER_DOES_MAP_RECTANGLE, 36, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {612.,792.}, /* default page width, height - points */ {72.,72.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 5cd584499..b4fb04cd3 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -447,7 +447,7 @@ gvrender_features_t svg_features = { | GVRENDER_DOES_TOOLTIPS, /* flags */ DEFAULT_EMBED_MARGIN, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ svg_knowncolors, /* knowncolors */ sizeof(svg_knowncolors) / sizeof(char *), /* sizeof knowncolors */ diff --git a/plugin/gd/gvrender_gd.c b/plugin/gd/gvrender_gd.c index 0bd05afb7..7363c6ee4 100644 --- a/plugin/gd/gvrender_gd.c +++ b/plugin/gd/gvrender_gd.c @@ -571,7 +571,7 @@ static gvrender_features_t gdgen_features_tc = { | GVRENDER_Y_GOES_DOWN, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ @@ -584,7 +584,7 @@ static gvrender_features_t gdgen_features = { GVRENDER_Y_GOES_DOWN, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ diff --git a/plugin/gd/gvrender_gd_vrml.c b/plugin/gd/gvrender_gd_vrml.c index 6977c3a7a..a879af53a 100644 --- a/plugin/gd/gvrender_gd_vrml.c +++ b/plugin/gd/gvrender_gd_vrml.c @@ -834,7 +834,7 @@ static gvrender_features_t vrml_features = { GVRENDER_DOES_Z, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {72.,72.}, /* default dpi */ NULL, /* knowncolors */ 0, /* sizeof knowncolors */ diff --git a/plugin/pango/gvrender_pango.c b/plugin/pango/gvrender_pango.c index 18bbdb2cf..a05fbeffc 100644 --- a/plugin/pango/gvrender_pango.c +++ b/plugin/pango/gvrender_pango.c @@ -408,7 +408,7 @@ static gvrender_features_t cairogen_features = { | GVRENDER_DOES_TRANSFORM, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {96.,96.}, /* default dpi */ 0, /* knowncolors */ 0, /* sizeof knowncolors */ @@ -423,7 +423,7 @@ static gvrender_features_t cairogen_features_ps = { | GVRENDER_DOES_TRANSFORM, /* flags */ 36, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {72.,72.}, /* postscript 72 dpi */ 0, /* knowncolors */ 0, /* sizeof knowncolors */ @@ -439,7 +439,7 @@ static gvrender_features_t cairogen_features_x = { | GVRENDER_X11_EVENTS, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {72.,72.}, /* default dpi */ 0, /* knowncolors */ 0, /* sizeof knowncolors */ @@ -455,7 +455,7 @@ static gvrender_features_t cairogen_features_gtk = { | GVRENDER_X11_EVENTS, /* flags */ 0, /* default margin - points */ 4., /* default pad - graph units */ - {0,0}, /* default height, width - device units */ + {0.,0.}, /* default page width, height - points */ {72.,72.}, /* default dpi */ 0, /* knowncolors */ 0, /* sizeof knowncolors */ -- 2.40.0