[dia] DiaRenderer: replace fill_bezier with draw_beziergon ...



commit 5978d9f58914198397cf353d0ff517cb6ae528b8
Author: Hans Breuer <hans breuer org>
Date:   Sat Apr 26 19:16:04 2014 +0200

    DiaRenderer: replace fill_bezier with draw_beziergon ...
    
    With the previous API it was not possible to stroke closed Bézier curves,
    leading to artifacts where lines are joined. The new draw_beziergon method
    takes fill and stroke color, thus also allowing to optimize for backends
    which can fill and stroke in one step (e.g. SVG, Shape, WPG?).
    For symmetry the signature of draw_arc, draw_ellipse and draw_polygon
    should also be adapted to take the extra fill color. The respective fill
    methods are than superfluous. Also more compact files get created, usually
    with a single graphic element per standard object.
    
    As the first step the object rendering code is only adapted, but not
    necessarily optimized to remove the extra "stroke call". Further commits
    will optimize draw_bezier some more before going to draw_polygon

 bindings/dia-renderer.cpp                 |    4 +-
 bindings/dia-renderer.h                   |    4 +-
 bindings/makefile.msc                     |    2 +-
 lib/arrows.c                              |    7 +--
 lib/diaimportrenderer.c                   |   26 ++++++-----
 lib/diapathrenderer.c                     |   23 +++++-----
 lib/diarenderer.c                         |   59 +++++++++++++++----------
 lib/diarenderer.h                         |   10 ++--
 lib/diasvgrenderer.c                      |   46 +++++++++++++------
 lib/diatransformrenderer.c                |   28 +++++++-----
 lib/standard-path.c                       |   10 +++-
 objects/AADL/aadlmemory.c                 |    3 +-
 objects/AADL/aadlport.c                   |    3 +-
 objects/AADL/aadlsystem.c                 |    3 +-
 objects/Istar/goal.c                      |    3 +-
 objects/KAOS/goal.c                       |    3 +-
 objects/KAOS/metaandorrel.c               |   10 ++---
 objects/custom/custom_object.c            |   15 ++++--
 objects/standard/beziergon.c              |    7 +--
 objects/standard/outline.c                |    2 +-
 plug-ins/cairo/diacairo-renderer.c        |   28 +++++++-----
 plug-ins/cgm/cgm.c                        |   22 +++++----
 plug-ins/drs/dia-render-script-import.c   |    8 ++-
 plug-ins/drs/dia-render-script-renderer.c |   34 ++++++++------
 plug-ins/libart/dialibartrenderer.c       |   69 +++++++++++++++++-----------
 plug-ins/metapost/render_metapost.c       |   39 ++++++++++------
 plug-ins/pgf/render_pgf.c                 |   30 ++++++++-----
 plug-ins/postscript/diapsrenderer.c       |   17 +++++---
 plug-ins/postscript/render_eps.c          |    2 +-
 plug-ins/pstricks/render_pstricks.c       |   33 +++++++++-----
 plug-ins/python/diasvg.py                 |   27 ++++++-----
 plug-ins/python/pydia-render.c            |   56 ++++++++++++++++++++++-
 plug-ins/vdx/vdx-export.c                 |   24 ++++------
 plug-ins/wmf/wmf.cpp                      |   31 ++++++++-----
 plug-ins/wpg/wpg-import.c                 |    5 +-
 plug-ins/wpg/wpg.c                        |   44 +++++++++++--------
 plug-ins/xfig/xfig-export.c               |   27 +++++++-----
 37 files changed, 465 insertions(+), 299 deletions(-)
---
diff --git a/bindings/dia-renderer.cpp b/bindings/dia-renderer.cpp
index 4834a15..41d41f0 100644
--- a/bindings/dia-renderer.cpp
+++ b/bindings/dia-renderer.cpp
@@ -187,10 +187,10 @@ dia::Renderer::draw_bezier (BezPoint *points, int numpoints, Color *color)
 }
 // fill a bezier line - possibly as approximation consisting of a polygon
 void 
-dia::Renderer::fill_bezier (BezPoint *points, int numpoints, Color *color)
+dia::Renderer::draw_beziergon (BezPoint *points, int numpoints, Color *fill, Color *stroke)
 {
     assert (self);
-    DIA_RENDERER_GET_CLASS(self)->fill_bezier (self, points, numpoints, color);
+    DIA_RENDERER_GET_CLASS(self)->draw_beziergon (self, points, numpoints, fill, stroke);
 }
 // drawing a polyline - or fallback to single line segments
 void 
diff --git a/bindings/dia-renderer.h b/bindings/dia-renderer.h
index 8224a3e..9262844 100644
--- a/bindings/dia-renderer.h
+++ b/bindings/dia-renderer.h
@@ -112,9 +112,9 @@ public :
     //! draw a bezier line - possibly as approximation consisting of straight lines
     //! \ingroup RenderMedium
     virtual void draw_bezier (BezPoint *points, int numpoints, Color *color);
-    //! fill a bezier line - possibly as approximation consisting of a polygon
+    //! fill and/or stroke a bezier - possibly as approximation consisting of a polygon
     //! \ingroup RenderMedium
-    virtual void fill_bezier (BezPoint *points, int numpoints, Color *color);
+    virtual void draw_beziergon (BezPoint *points, int numpoints, Color *fill, Color *stroke);
     //! drawing a polyline - or fallback to single line segments
     //! \ingroup RenderMedium
     virtual void draw_polyline (Point *points, int num_points, Color *color);
diff --git a/bindings/makefile.msc b/bindings/makefile.msc
index 3b77dca..d540f39 100644
--- a/bindings/makefile.msc
+++ b/bindings/makefile.msc
@@ -3,7 +3,7 @@ TOP = ..\..
 !INCLUDE $(PRJ_TOP)\dia-make.msc
 
 !IFNDEF PYTHON_VERSION
-PYTHON_VERSION=23
+PYTHON_VERSION=27
 !ENDIF
 !IFNDEF PYTHON
 PYTHON = ..\..\..\python$(PYTHON_VERSION)
diff --git a/lib/arrows.c b/lib/arrows.c
index 2990893..ac945e0 100644
--- a/lib/arrows.c
+++ b/lib/arrows.c
@@ -634,10 +634,9 @@ draw_fill_ellipse(DiaRenderer *renderer, Point *to, Point *from,
   point_copy_add_scaled(&bp[2].p1,&bp[1].p3,&vl,length / 4.0);
   point_copy_add_scaled(&bp[3].p2,&bp[3].p3,&vl,length / 4.0);
   if (bg_color) {
-    DIA_RENDERER_GET_CLASS(renderer)->fill_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),bg_color);
-    DIA_RENDERER_GET_CLASS(renderer)->draw_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color);
+    DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon(renderer,bp,sizeof(bp)/sizeof(bp[0]),bg_color,fg_color);
   } else {
-    DIA_RENDERER_GET_CLASS(renderer)->fill_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color);
+    DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color,NULL);
   }
 }
 
@@ -868,7 +867,7 @@ draw_fill_dot(DiaRenderer *renderer, Point *to, Point *from,
     
     DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer,&dos,&doe,fg_color);
   } else {
-    DIA_RENDERER_GET_CLASS(renderer)->fill_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),bg_color);
+    DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon(renderer,bp,sizeof(bp)/sizeof(bp[0]),bg_color,NULL);
   }
   if (fg_color != bg_color) {
     DIA_RENDERER_GET_CLASS(renderer)->draw_bezier(renderer,bp,sizeof(bp)/sizeof(bp[0]),fg_color);
diff --git a/lib/diaimportrenderer.c b/lib/diaimportrenderer.c
index 7f0dc73..82726f0 100644
--- a/lib/diaimportrenderer.c
+++ b/lib/diaimportrenderer.c
@@ -71,10 +71,11 @@ static void draw_bezier (DiaRenderer *renderer,
                         BezPoint *points,
                         int numpoints,
                         Color *color);
-static void fill_bezier (DiaRenderer *renderer,
-                        BezPoint *points,
-                        int numpoints,
-                        Color *color);
+static void draw_beziergon (DiaRenderer *renderer,
+                           BezPoint *points,
+                           int numpoints,
+                           Color *fill,
+                           Color *stroke);
 static void draw_string (DiaRenderer *renderer,
                         const gchar *text,
                         Point *pos,
@@ -190,7 +191,7 @@ dia_import_renderer_class_init (DiaImportRendererClass *klass)
 
   /* medium level functions */
   renderer_class->draw_bezier  = draw_bezier;
-  renderer_class->fill_bezier  = fill_bezier;
+  renderer_class->draw_beziergon  = draw_beziergon;
   renderer_class->draw_rect = draw_rect;
   renderer_class->draw_rounded_polyline  = draw_rounded_polyline;
   renderer_class->draw_polyline  = draw_polyline;
@@ -422,9 +423,9 @@ fill_arc (DiaRenderer *renderer, Point *center,
 #else
   GArray *path = g_array_new (FALSE, FALSE, sizeof(BezPoint));
   path_build_arc (path, center, width, height, angle1, angle2, TRUE);
-  DIA_RENDERER_GET_CLASS(renderer)->fill_bezier (renderer,
-                                                &g_array_index (path, BezPoint, 0),
-                                                path->len, color);
+  DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon (renderer,
+                                                   &g_array_index (path, BezPoint, 0),
+                                                   path->len, color, NULL);
   g_array_free (path, TRUE);
 #endif
 }
@@ -540,16 +541,17 @@ draw_bezier (DiaRenderer *renderer,
  * \memberof _DiaImportRenderer
  */
 static void
-fill_bezier (DiaRenderer *renderer,
-             BezPoint *points, int numpoints,
-             Color *color)
+draw_beziergon (DiaRenderer *renderer,
+                BezPoint *points, int numpoints,
+                Color *fill,
+                Color *stroke)
 {
   DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
   DiaObject *object;
 
   g_return_if_fail (numpoints > 2);
   object = create_standard_beziergon (numpoints, points);
-  _apply_style (self, object, color, NULL, 0.0);
+  _apply_style (self, object, fill, stroke, 0.0);
   _push_object (self, object);
 }
 
diff --git a/lib/diapathrenderer.c b/lib/diapathrenderer.c
index b7ec40b..de1058d 100644
--- a/lib/diapathrenderer.c
+++ b/lib/diapathrenderer.c
@@ -571,7 +571,7 @@ fill_ellipse (DiaRenderer *self,
 static void
 _bezier (DiaRenderer *self, 
         BezPoint *points, int numpoints,
-        const Color *stroke, const Color *fill)
+        const Color *fill, const Color *stroke)
 {
   DiaPathRenderer *renderer = DIA_PATH_RENDERER (self);
   GArray *path = _get_current_path (renderer, stroke, fill);
@@ -586,7 +586,7 @@ _bezier (DiaRenderer *self,
   }
   for (; i < numpoints; ++i)
     g_array_append_val (path, points[i]);
-  if (fill)
+  if (fill) /* might not be necessary anymore with draw_beziergon*/
     _path_lineto (path, &points[0].p1);
 }
 static void
@@ -595,16 +595,17 @@ draw_bezier (DiaRenderer *self,
             int numpoints,
             Color *color)
 {
-  _bezier(self, points, numpoints, color, NULL);
+  _bezier(self, points, numpoints, NULL, color);
   _remove_duplicated_path (DIA_PATH_RENDERER (self));
 }
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-  _bezier(self, points, numpoints, NULL, color);
+  _bezier(self, points, numpoints, fill, stroke);
 }
 /*!
  * \brief Convert the text object to a scaled path
@@ -742,9 +743,9 @@ dia_path_renderer_class_init (DiaPathRendererClass *klass)
   renderer_class->draw_polyline  = draw_polyline;
   renderer_class->draw_polygon   = draw_polygon;
 
-  renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
-  renderer_class->draw_text     = draw_text;
+  renderer_class->draw_bezier    = draw_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
+  renderer_class->draw_text      = draw_text;
   /* other */
   renderer_class->is_capable_to = is_capable_to;
 }
diff --git a/lib/diarenderer.c b/lib/diarenderer.c
index 877e0cf..e0a6873 100644
--- a/lib/diarenderer.c
+++ b/lib/diarenderer.c
@@ -95,10 +95,11 @@ static void draw_bezier (DiaRenderer *renderer,
                          BezPoint *points,
                          int numpoints,
                          Color *color);
-static void fill_bezier (DiaRenderer *renderer,
-                         BezPoint *points,
-                         int numpoints,
-                         Color *color);
+static void draw_beziergon (DiaRenderer *renderer,
+                            BezPoint *points,
+                            int numpoints,
+                            Color *fill,
+                            Color *stroke);
 static void draw_string (DiaRenderer *renderer,
                          const gchar *text,
                          Point *pos,
@@ -334,7 +335,7 @@ dia_renderer_class_init (DiaRendererClass *klass)
 
   /* medium level functions */
   renderer_class->draw_bezier  = draw_bezier;
-  renderer_class->fill_bezier  = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
   renderer_class->draw_rect = draw_rect;
   renderer_class->draw_rounded_polyline  = draw_rounded_polyline;
   renderer_class->draw_polyline  = draw_polyline;
@@ -723,12 +724,14 @@ draw_bezier (DiaRenderer *renderer,
 }
 
 static void 
-fill_bezier (DiaRenderer *renderer,
-             BezPoint *points, int numpoints,
-             Color *color)
+draw_beziergon (DiaRenderer *renderer,
+                BezPoint *points, int numpoints,
+                Color *fill, Color *stroke)
 {
   BezierApprox *bezier;
 
+  g_return_if_fail (fill != NULL || stroke != NULL);
+
   if (renderer->bezier)
     bezier = renderer->bezier;
   else
@@ -742,10 +745,16 @@ fill_bezier (DiaRenderer *renderer,
   bezier->currpoint = 0;
   approximate_bezier (bezier, points, numpoints);
 
-  DIA_RENDERER_GET_CLASS (renderer)->fill_polygon (renderer,
-                                                   bezier->points,
-                                                   bezier->currpoint,
-                                                   color);
+  if (fill)
+    DIA_RENDERER_GET_CLASS (renderer)->fill_polygon (renderer,
+                                                     bezier->points,
+                                                     bezier->currpoint,
+                                                     fill);
+  if (stroke)
+    DIA_RENDERER_GET_CLASS (renderer)->draw_polygon (renderer,
+                                                     bezier->points,
+                                                     bezier->currpoint,
+                                                     stroke);
 }
 
 static void 
@@ -909,9 +918,9 @@ _rounded_rect_with_bezier (DiaRenderer *renderer,
   /* end of copy */
 
   if (fill)
-    DIA_RENDERER_GET_CLASS(renderer)->fill_bezier (renderer, points, num_points, color);
+    DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon (renderer, points, num_points, color, NULL);
   else
-    DIA_RENDERER_GET_CLASS(renderer)->draw_bezier (renderer, points, num_points, color);
+    DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon (renderer, points, num_points, NULL, color);
 }
 
 static void 
@@ -985,8 +994,8 @@ fill_rounded_rect(DiaRenderer *renderer,
     renderer_ops->fill_rect(renderer, ul_corner, lr_corner, color);
     return;
   }
-  /* if the renderer has it's own fill_bezier use that */
-  if (DIA_RENDERER_GET_CLASS(renderer)->fill_bezier != &fill_bezier) {
+  /* if the renderer has it's own draw_beziergon use that */
+  if (DIA_RENDERER_GET_CLASS(renderer)->draw_beziergon != &draw_beziergon) {
     _rounded_rect_with_bezier (renderer, ul_corner, lr_corner, color, radius, TRUE);
     return;
   }
@@ -1643,7 +1652,7 @@ bezier_render_fill (DiaRenderer *renderer, BezPoint *pts, int total, Color *colo
     }
   }
   if (!needs_split) {
-    DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, pts, total, color);
+    DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer, pts, total, color, NULL);
   } else {
     GArray *points = g_array_new (FALSE, FALSE, sizeof(BezPoint));
     Point close_to;
@@ -1662,7 +1671,9 @@ bezier_render_fill (DiaRenderer *renderer, BezPoint *pts, int total, Color *colo
            bp.p1 = close_to;
            g_array_append_val(points, bp);
          }
-         DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &g_array_index(points, BezPoint, 0), 
points->len, color);
+         DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer,
+                                                            &g_array_index(points, BezPoint, 0), points->len,
+                                                            color, NULL);
          g_array_set_size (points, 0);
          g_array_append_val(points, pts[i]); /* new needs move-to */
          needs_close = FALSE;
@@ -1682,7 +1693,9 @@ bezier_render_fill (DiaRenderer *renderer, BezPoint *pts, int total, Color *colo
     if (points->len > 1) {
       /* actually most renderers need at least three points, but having only one
        * point is an artifact coming from the algorithm above: "new needs move-to" */
-      DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &g_array_index(points, BezPoint, 0), 
points->len, color);
+      DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer,
+                                                        &g_array_index(points, BezPoint, 0), points->len,
+                                                        color, NULL);
     }
     g_array_free (points, TRUE);
   }
@@ -1706,10 +1719,10 @@ bezier_render_fill_old (DiaRenderer *renderer, BezPoint *pts, int total, Color *
       real dist = distance_bez_shape_point (&pts[s1],  n1 > 0 ? n1 : i - s1, 0, &pts[i].p1);
       if (s2 > s1) { /* blanking the previous one */
        n = i - s2 - 1;
-       DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s2], n, &color_white);
+       DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer, &pts[s2], n, &color_white, NULL);
       } else { /* fill the outer shape */
        n1 = n = i - s1;
-       DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s1], n, color);
+       DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer, &pts[s1], n, color, NULL);
       }
       if (dist > 0) { /* remember as new outer outline */
        s1 = i;
@@ -1723,10 +1736,10 @@ bezier_render_fill_old (DiaRenderer *renderer, BezPoint *pts, int total, Color *
   /* the last one is not drawn yet, i is pointing to the last element */
   if (s2 > s1) { /* blanking the previous one */
     if (i - s2 - 1 > 1) /* depending on the above we may be ready */
-      DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s2], i - s2, &color_white);
+      DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer, &pts[s2], i - s2, &color_white, NULL);
   } else {
     if (i - s1 - 1 > 1)
-      DIA_RENDERER_GET_CLASS (renderer)->fill_bezier (renderer, &pts[s1], i - s1, color);
+      DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon (renderer, &pts[s1], i - s1, color, NULL);
   }
 }
 
diff --git a/lib/diarenderer.h b/lib/diarenderer.h
index 8cc2857..12c393b 100644
--- a/lib/diarenderer.h
+++ b/lib/diarenderer.h
@@ -186,18 +186,18 @@ struct _DiaRendererClass
                        BezPoint *points,
                        int numpoints,
                        Color *color);
-  /*! Same as DrawBezierFunc, except the last point must be the same as the
-     first point, and the resulting shape is filled */
-  void (*fill_bezier) (DiaRenderer *renderer,
+  /*! Fill and/or stroke a  closed bezier */
+  void (*draw_beziergon) (DiaRenderer *renderer,
                        BezPoint *points,
                        int numpoints,
-                       Color *color);
+                       Color *fill,
+                       Color *stroke);
   /*! Draw a line joining multiple points, using color and the current
      line style */
   void (*draw_polyline) (DiaRenderer *renderer,
                          Point *points, int num_points,
                          Color *color);
-  /*! Draw a polygone, using the current line style
+  /*! Draw a polygon, using the current line style
      The polygon is closed even if the first point is not the same as the
      last point */
   void (*draw_polygon) (DiaRenderer *renderer,
diff --git a/lib/diasvgrenderer.c b/lib/diasvgrenderer.c
index 30d6f15..3dea5dc 100644
--- a/lib/diasvgrenderer.c
+++ b/lib/diasvgrenderer.c
@@ -371,10 +371,10 @@ get_draw_style(DiaSvgRenderer *renderer,
   gchar linewidth_buf[DTOSTR_BUF_SIZE];
   gchar alpha_buf[DTOSTR_BUF_SIZE];
 
-  if (!str) str = g_string_new(NULL);
+  if (!str)
+    str = g_string_new(NULL);
   g_string_truncate(str, 0);
 
-  /* TODO(CHECK): the shape-export didn't have 'fill: none' here */
   g_string_printf(str, "fill: none; stroke-opacity: %s; stroke-width: %s", 
                  g_ascii_formatd (alpha_buf, sizeof(alpha_buf), "%g", colour->alpha), 
                  dia_svg_dtostr(linewidth_buf, renderer->linewidth) );
@@ -698,8 +698,9 @@ static void
 _bezier(DiaRenderer *self, 
        BezPoint *points,
        int numpoints,
-       Color *colour,
-       gboolean fill)
+       Color *fill,
+       Color *stroke,
+       gboolean closed)
 {
   DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
   int i;
@@ -713,9 +714,18 @@ _bezier(DiaRenderer *self,
   gchar p3y_buf[DTOSTR_BUF_SIZE];
 
   node = xmlNewChild(renderer->root, renderer->svg_name_space, (const xmlChar *)"path", NULL);
-  
-  xmlSetProp(node, (const xmlChar *)"style",
-            (xmlChar *)(fill ? get_fill_style(renderer, colour) : get_draw_style(renderer, colour)));
+
+  if (fill || stroke) {
+    GString *style = str = g_string_new("");
+
+    if (stroke) /* XXX: sets also fill:none - so it must be first to get overwritten;) */
+      g_string_append_printf (str, "%s;", get_draw_style(renderer, stroke));
+    if (fill)
+      g_string_append_printf (str, "%s;", get_fill_style(renderer, fill));
+    xmlSetProp(node, (const xmlChar *)"style", (xmlChar *)style->str);
+
+    g_string_free(style, TRUE);
+  }
 
   str = g_string_new(NULL);
 
@@ -767,18 +777,24 @@ static void
 draw_bezier(DiaRenderer *self, 
            BezPoint *points,
            int numpoints,
-           Color *colour)
+           Color *stroke)
 {
-  _bezier(self, points, numpoints, colour, FALSE);
+  _bezier(self, points, numpoints, NULL, stroke, FALSE);
 }
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *colour)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-  _bezier(self, points, numpoints, colour, TRUE);
+  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
+  /* optimize for stroke-width==0 && fill==stroke */
+  if (   fill && stroke && renderer->linewidth == 0.0
+      && memcmp(fill, stroke, sizeof(Color))==0)
+    stroke = NULL;
+  _bezier(self, points, numpoints, fill, stroke, TRUE);
 }
 
 static void
@@ -1001,7 +1017,7 @@ dia_svg_renderer_class_init (DiaSvgRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
   renderer_class->draw_text_line  = draw_text_line;
 
   /* SVG specific */
diff --git a/lib/diatransformrenderer.c b/lib/diatransformrenderer.c
index e0f6827..e0f6449 100644
--- a/lib/diatransformrenderer.c
+++ b/lib/diatransformrenderer.c
@@ -319,7 +319,8 @@ fill_rect (DiaRenderer *self,
 static void
 _bezier (DiaRenderer *self, 
         BezPoint *points, int num_points,
-        Color *stroke, Color *fill)
+        Color *fill, Color *stroke,
+        gboolean closed)
 {
   BezPoint *a_pts = g_newa (BezPoint, num_points);
   DiaTransformRenderer *renderer = DIA_TRANSFORM_RENDERER (self);
@@ -331,10 +332,12 @@ _bezier (DiaRenderer *self,
     for (i = 0; i < num_points; ++i)
       transform_bezpoint (&a_pts[i], m);
   }
-  if (fill)
-    DIA_RENDERER_GET_CLASS (renderer->worker)->fill_bezier (renderer->worker, a_pts, num_points, fill);
+  if (closed)
+    DIA_RENDERER_GET_CLASS (renderer->worker)->draw_beziergon (renderer->worker, a_pts, num_points, fill, 
stroke);
   else
     DIA_RENDERER_GET_CLASS (renderer->worker)->draw_bezier (renderer->worker, a_pts, num_points, stroke);
+  if (!closed)
+    g_return_if_fail (fill == NULL && "fill for stroke?");
 }
 static void
 _arc (DiaRenderer *self, 
@@ -345,7 +348,7 @@ _arc (DiaRenderer *self,
 {
   GArray *path = g_array_new (FALSE, FALSE, sizeof(BezPoint));
   path_build_arc (path, center, width, height, angle1, angle2, stroke == NULL);
-  _bezier (self, &g_array_index (path, BezPoint, 0), path->len, stroke, fill);
+  _bezier (self, &g_array_index (path, BezPoint, 0), path->len, fill, stroke, fill!=NULL);
   g_array_free (path, TRUE);
 }
 /*!
@@ -382,7 +385,7 @@ _ellipse (DiaRenderer *self,
 {
   GArray *path = g_array_new (FALSE, FALSE, sizeof(BezPoint));
   path_build_ellipse (path, center, width, height);
-  _bezier (self, &g_array_index (path, BezPoint, 0), path->len, stroke, fill);
+  _bezier (self, &g_array_index (path, BezPoint, 0), path->len, fill, stroke, fill!=NULL);
   g_array_free (path, TRUE);
 }
 /*!
@@ -419,19 +422,20 @@ draw_bezier (DiaRenderer *self,
             int numpoints,
             Color *color)
 {
-  _bezier(self, points, numpoints, color, NULL);
+  _bezier(self, points, numpoints, NULL, color, FALSE);
 }
 /*!
  * \brief Transform bezier and delegate fill
  * \memberof _DiaTransformRenderer
  */
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points, /* Last point must be same as first point */
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-  _bezier(self, points, numpoints, NULL, color);
+  _bezier(self, points, numpoints, fill, stroke, TRUE);
 }
 /*!
  * \brief Transform the text object while drawing
@@ -583,7 +587,7 @@ dia_transform_renderer_class_init (DiaTransformRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
   renderer_class->draw_text     = draw_text;
   /* other */
   renderer_class->is_capable_to = is_capable_to;
diff --git a/lib/standard-path.c b/lib/standard-path.c
index 4a90ca9..fdefb26 100644
--- a/lib/standard-path.c
+++ b/lib/standard-path.c
@@ -425,12 +425,16 @@ stdpath_draw(StdPath *stdpath, DiaRenderer *renderer)
        if (DIA_RENDERER_GET_CLASS (renderer)->is_capable_to(renderer, RENDER_PATTERN))
          DIA_RENDERER_GET_CLASS (renderer)->set_pattern (renderer, stdpath->pattern);
       }
-      DIA_RENDERER_GET_CLASS (renderer)->fill_bezier(renderer, stdpath->points, stdpath->num_points, 
-                                                    &fill);
+      if (stdpath->stroke_or_fill & PDO_STROKE) /* also stroke -> combine */
+        DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon(renderer, stdpath->points, stdpath->num_points, 
+                                                         &fill, &stdpath->line_color);
+      else
+        DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon(renderer, stdpath->points, stdpath->num_points, 
+                                                         &fill, NULL);
       if (DIA_RENDERER_GET_CLASS (renderer)->is_capable_to(renderer, RENDER_PATTERN))
        DIA_RENDERER_GET_CLASS (renderer)->set_pattern (renderer, NULL);
     }
-    if (stdpath->stroke_or_fill & PDO_STROKE)
+    if (stdpath->stroke_or_fill == PDO_STROKE) /* stroke only */
       DIA_RENDERER_GET_CLASS (renderer)->draw_bezier(renderer, stdpath->points, stdpath->num_points, 
                                                     &stdpath->line_color);
   } else {
diff --git a/objects/AADL/aadlmemory.c b/objects/AADL/aadlmemory.c
index ae2c308..7bf2d50 100755
--- a/objects/AADL/aadlmemory.c
+++ b/objects/AADL/aadlmemory.c
@@ -74,8 +74,7 @@ static void aadlmemory_draw_borders(Aadlbox *aadlbox, DiaRenderer *renderer)
   renderer_ops->set_linewidth(renderer, AADLBOX_BORDERWIDTH);
   renderer_ops->set_linestyle(renderer, LINESTYLE_SOLID);
 
-  renderer_ops->fill_bezier(renderer, bez, 5, &aadlbox->fill_color);
-  renderer_ops->draw_bezier(renderer, bez, 5, &aadlbox->line_color);
+  renderer_ops->draw_beziergon(renderer, bez, 5, &aadlbox->fill_color, &aadlbox->line_color);
 
   bez[1].p1.x = x;
   bez[1].p1.y = y + 2*h*AADL_MEMORY_FACTOR;
diff --git a/objects/AADL/aadlport.c b/objects/AADL/aadlport.c
index 9c20dca..2b16220 100755
--- a/objects/AADL/aadlport.c
+++ b/objects/AADL/aadlport.c
@@ -426,8 +426,7 @@ aadlbox_draw_port(Aadlport *port, DiaRenderer *renderer)
        }
       }
       
-      renderer_ops->fill_bezier(renderer, b, 5, &color_black);
-      renderer_ops->draw_bezier(renderer, b, 5, &color_black);
+      renderer_ops->draw_beziergon(renderer, b, 5, &color_black, &color_black);
       
     }
     break;
diff --git a/objects/AADL/aadlsystem.c b/objects/AADL/aadlsystem.c
index d243ced..5b16d3a 100755
--- a/objects/AADL/aadlsystem.c
+++ b/objects/AADL/aadlsystem.c
@@ -90,8 +90,7 @@ void aadlbox_draw_rounded_box (Aadlbox *aadlbox, DiaRenderer *renderer,
   renderer_ops->set_linestyle(renderer, linestyle);
   renderer_ops->set_dashlength(renderer, AADLBOX_DASH_LENGTH);
 
-  renderer_ops->fill_bezier(renderer, bez, 9, &aadlbox->fill_color);
-  renderer_ops->draw_bezier(renderer, bez, 9, &aadlbox->line_color);
+  renderer_ops->draw_beziergon(renderer, bez, 9, &aadlbox->fill_color, &aadlbox->line_color);
 }
 
 
diff --git a/objects/Istar/goal.c b/objects/Istar/goal.c
index 13e0c67..7d07579 100644
--- a/objects/Istar/goal.c
+++ b/objects/Istar/goal.c
@@ -335,8 +335,7 @@ goal_draw(Goal *goal, DiaRenderer *renderer)
   } else {                 /* softgoal */
      compute_cloud(goal,bpl);
      renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-     renderer_ops->fill_bezier(renderer,bpl,5,&GOAL_BG_COLOR);
-     renderer_ops->draw_bezier(renderer,bpl,5,&GOAL_FG_COLOR);
+     renderer_ops->draw_beziergon(renderer,bpl,5,&GOAL_BG_COLOR,&GOAL_FG_COLOR);
   }
 
   /* drawing text */
diff --git a/objects/KAOS/goal.c b/objects/KAOS/goal.c
index c3612c5..d22a001 100644
--- a/objects/KAOS/goal.c
+++ b/objects/KAOS/goal.c
@@ -423,8 +423,7 @@ goal_draw(Goal *goal, DiaRenderer *renderer)
   } else { /* SOFTGOAL IS HERE */
      compute_cloud(goal,bpl);
      renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
-     renderer_ops->fill_bezier(renderer,bpl,9,&GOAL_BG_COLOR);
-     renderer_ops->draw_bezier(renderer,bpl,9,&GOAL_FG_COLOR);
+     renderer_ops->draw_beziergon(renderer,bpl,9,&GOAL_BG_COLOR,&GOAL_FG_COLOR);
   }
 
   /* drawing text */
diff --git a/objects/KAOS/metaandorrel.c b/objects/KAOS/metaandorrel.c
index 9ecb18a..29b43ee 100644
--- a/objects/KAOS/metaandorrel.c
+++ b/objects/KAOS/metaandorrel.c
@@ -452,24 +452,22 @@ maor_draw(Maor *maor, DiaRenderer *renderer)
   switch (maor->type) {
     case MAOR_AND_REF:
       compute_and(&p1,MAOR_REF_WIDTH,MAOR_REF_HEIGHT,bpl);
-      renderer_ops->fill_bezier(renderer,bpl,6,&MAOR_BG_COLOR);
-      renderer_ops->draw_bezier(renderer,bpl,6,&MAOR_FG_COLOR);
+      renderer_ops->draw_beziergon(renderer,bpl,6,&MAOR_BG_COLOR,&MAOR_FG_COLOR);
       break;
 
     case MAOR_AND_COMP_REF:
       compute_and(&p1,MAOR_REF_WIDTH,MAOR_REF_HEIGHT,bpl);
-      renderer_ops->fill_bezier(renderer,bpl,6,&MAOR_FG_COLOR);
+      renderer_ops->draw_beziergon(renderer,bpl,6,&MAOR_FG_COLOR,NULL);
       break;
 
     case MAOR_OR_REF:
       compute_or(&p1,MAOR_REF_WIDTH,MAOR_REF_HEIGHT,bpl);
-      renderer_ops->fill_bezier(renderer,bpl,4,&MAOR_BG_COLOR);
-      renderer_ops->draw_bezier(renderer,bpl,4,&MAOR_FG_COLOR);
+      renderer_ops->draw_beziergon(renderer,bpl,4,&MAOR_BG_COLOR,&MAOR_FG_COLOR);
       break;
 
     case MAOR_OR_COMP_REF:
       compute_or(&p1,MAOR_REF_WIDTH,MAOR_REF_HEIGHT,bpl);
-      renderer_ops->fill_bezier(renderer,bpl,4,&MAOR_FG_COLOR);
+      renderer_ops->draw_beziergon(renderer,bpl,4,&MAOR_FG_COLOR,NULL);
       break;
 
     case MAOR_OPER_REF:
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index b8d27ff..564af6f 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -916,7 +916,11 @@ custom_draw_element(GraphicElement* el, Custom *custom, DiaRenderer *renderer,
   int i;
   real radius;
 
-  if (el->any.s.line_width != (*cur_line)) {
+  /* Somewhow - maybe due to scaling - the exact match does not always work. Instead of:
+   *   (el->any.s.line_width != (*cur_line))
+   * be more tolerant to avoid using completely wrong line width.
+   */
+  if (fabs (el->any.s.line_width - (*cur_line)) > 0.001) {
     (*cur_line) = el->any.s.line_width;
     renderer_ops->set_linewidth(renderer,
                  custom->border_width*(*cur_line));
@@ -1055,9 +1059,10 @@ custom_draw_element(GraphicElement* el, Custom *custom, DiaRenderer *renderer,
               &g_array_index(barr, BezPoint, i).p1);
     }
     if (custom->show_background && el->any.s.fill != DIA_SVG_COLOUR_NONE)
-      renderer_ops->fill_bezier(renderer, (BezPoint *)barr->data,
-                                 el->path.npoints, bg);
-    if (el->any.s.stroke != DIA_SVG_COLOUR_NONE)
+      renderer_ops->draw_beziergon(renderer,
+                                  (BezPoint *)barr->data, el->path.npoints,
+                                  bg, (el->any.s.stroke != DIA_SVG_COLOUR_NONE) ? fg : NULL);
+    else if (el->any.s.stroke != DIA_SVG_COLOUR_NONE)
       renderer_ops->draw_bezier(renderer, (BezPoint *)barr->data,
                                  el->path.npoints, fg);
     break;
@@ -1327,7 +1332,7 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
   }
 
   for (i = 0; i < info->nconnections; i++)
-    transform_coord(custom, &info->connections[i], &custom->connections[i].pos);  
elem->extra_spacing.border_trans = 0; /*custom->border_width/2; */
+    transform_coord(custom, &info->connections[i], &custom->connections[i].pos);
   elem->extra_spacing.border_trans = 0; /*custom->border_width/2; */
   element_update_boundingbox(elem);
 
diff --git a/objects/standard/beziergon.c b/objects/standard/beziergon.c
index e0c2173..9484eaf 100644
--- a/objects/standard/beziergon.c
+++ b/objects/standard/beziergon.c
@@ -237,13 +237,12 @@ beziergon_draw(Beziergon *beziergon, DiaRenderer *renderer)
       if (renderer_ops->is_capable_to(renderer, RENDER_PATTERN))
         renderer_ops->set_pattern (renderer, beziergon->pattern);
     }
-    renderer_ops->fill_bezier(renderer, points, n, &fill);
+    renderer_ops->draw_beziergon(renderer, points, n, &fill, &beziergon->line_color);
     if (renderer_ops->is_capable_to(renderer, RENDER_PATTERN))
       renderer_ops->set_pattern (renderer, NULL);
+  } else { /* still to be closed */
+    renderer_ops->draw_beziergon(renderer, points, n, NULL, &beziergon->line_color);
   }
-
-  renderer_ops->draw_bezier(renderer, points, n, &beziergon->line_color);
-
   /* these lines should only be displayed when object is selected.
    * Unfortunately the draw function is not aware of the selected
    * state.  This is a compromise until I fix this properly. */
diff --git a/objects/standard/outline.c b/objects/standard/outline.c
index db42d5a..9f093dc 100644
--- a/objects/standard/outline.c
+++ b/objects/standard/outline.c
@@ -406,7 +406,7 @@ outline_draw(Outline *outline, DiaRenderer *renderer)
 
   if (DIA_RENDERER_GET_CLASS (renderer)->is_capable_to(renderer, RENDER_HOLES)) {
     if (outline->show_background)
-      DIA_RENDERER_GET_CLASS (renderer)->fill_bezier(renderer, pts, total, &outline->fill_color);
+      DIA_RENDERER_GET_CLASS (renderer)->draw_beziergon(renderer, pts, total, &outline->fill_color, NULL);
     DIA_RENDERER_GET_CLASS (renderer)->draw_bezier (renderer, pts, total, &outline->line_color);
     return; /* that was easy ;) */
   }
diff --git a/plug-ins/cairo/diacairo-renderer.c b/plug-ins/cairo/diacairo-renderer.c
index 73ca022..659a99d 100644
--- a/plug-ins/cairo/diacairo-renderer.c
+++ b/plug-ins/cairo/diacairo-renderer.c
@@ -824,7 +824,8 @@ _bezier(DiaRenderer *self,
         BezPoint *points,
         int numpoints,
         Color *color,
-        gboolean fill)
+        gboolean fill,
+        gboolean closed)
 {
   DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
   int i;
@@ -856,10 +857,8 @@ _bezier(DiaRenderer *self,
     }
   }
 
-  /* The stroke would benefit by an explicit cairo_close_path() but we can not do it.
-   * At this point there is not enough information left, i.e. if it comes from a Beziergon
-   * and should be closed or if it was a Bezierline which happens to end in the start point.
-   */
+  if (closed)
+    cairo_close_path(renderer->cr);
   if (fill)
     _dia_cairo_fill (renderer);
   else
@@ -873,16 +872,21 @@ draw_bezier(DiaRenderer *self,
             int numpoints,
             Color *color)
 {
-  _bezier (self, points, numpoints, color, FALSE);
+  _bezier (self, points, numpoints, color, FALSE, FALSE);
 }
 
 static void
-fill_bezier(DiaRenderer *self, 
-            BezPoint *points,
-            int numpoints,
-            Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-  _bezier (self, points, numpoints, color, TRUE);
+  if (fill)
+    _bezier (self, points, numpoints, fill, TRUE, TRUE);
+  /* XXX: optimize if line_width is zero and fill==stroke */
+  if (stroke)
+    _bezier (self, points, numpoints, stroke, FALSE, TRUE);
 }
 
 static void
@@ -1263,7 +1267,7 @@ cairo_renderer_class_init (DiaCairoRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   /* highest level functions */
   renderer_class->draw_rounded_rect = draw_rounded_rect;
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index b80f483..62992f4 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -304,10 +304,11 @@ static void draw_bezier(DiaRenderer *self,
                        BezPoint *points,
                        int numpoints,
                        Color *colour);
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points, /* Last point must be same as first point */
-                       int numpoints,
-                       Color *colour);
+static void draw_beziergon(DiaRenderer *self, 
+                          BezPoint *points, /* Last point must be same as first point */
+                          int numpoints,
+                          Color *fill,
+                          Color *stroke);
 static void draw_string(DiaRenderer *self,
                        const char *text,
                        Point *pos, Alignment alignment,
@@ -1026,17 +1027,18 @@ draw_bezier(DiaRenderer *self,
 
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *colour)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points, /* Last point must be same as first point */
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
     CgmRenderer *renderer = CGM_RENDERER(self);
 
     if ( numpoints < 2 )
         return;
 
-    write_filledge_attributes(renderer, colour, NULL);
+    write_filledge_attributes(renderer, fill, stroke);
 
     /*
     ** A filled bezier is created by using it within a figure.
@@ -1379,7 +1381,7 @@ cgm_renderer_class_init (CgmRendererClass *klass)
     renderer_class->fill_ellipse = fill_ellipse;
 
     renderer_class->draw_bezier = draw_bezier;
-    renderer_class->fill_bezier = fill_bezier;
+    renderer_class->draw_beziergon = draw_beziergon;
 
     renderer_class->draw_string = draw_string;
 
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index 75b75fc..d93ca4e 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -319,9 +319,11 @@ _render_object (xmlNodePtr render, DiaContext *ctx)
       } else if (xmlStrcmp (node->name, (const xmlChar *)"bezier") == 0) {
        GArray *path = _parse_bezpoints (node, "bezpoints");
        if (path) {
-         if (fill)
-           ops->fill_bezier (ir, &g_array_index(path,BezPoint,0), path->len, fill);
-         if (stroke)
+         if (fill && stroke)
+           ops->draw_beziergon (ir, &g_array_index(path,BezPoint,0), path->len, fill, stroke);
+         else if (fill)
+           ops->draw_beziergon (ir, &g_array_index(path,BezPoint,0), path->len, fill, NULL);
+         else if (stroke)
            ops->draw_bezier (ir, &g_array_index(path,BezPoint,0), path->len, stroke);
          g_array_free (path, TRUE);
        }
diff --git a/plug-ins/drs/dia-render-script-renderer.c b/plug-ins/drs/dia-render-script-renderer.c
index d58dc63..fce674b 100644
--- a/plug-ins/drs/dia-render-script-renderer.c
+++ b/plug-ins/drs/dia-render-script-renderer.c
@@ -602,10 +602,10 @@ fill_ellipse(DiaRenderer *self,
 
 static void
 _bezier(DiaRenderer *self, 
-        BezPoint *points,
-        int numpoints,
-        Color *color,
-        gboolean fill)
+       BezPoint *points,
+       int numpoints,
+       Color *fill,
+       Color *stroke)
 {
   DrsRenderer *renderer = DRS_RENDERER (self);
   xmlNodePtr node;
@@ -614,9 +614,9 @@ _bezier(DiaRenderer *self,
                       (const xmlChar *)"bezier", NULL);
   _node_set_bezpoints (node, points, numpoints);
   if (fill)
-    _node_set_color (node, "fill", color);
-  else
-    _node_set_color (node, "stroke", color);
+    _node_set_color (node, "fill", fill);
+  if (stroke)
+    _node_set_color (node, "stroke", stroke);
 }
 static void
 draw_bezier(DiaRenderer *self, 
@@ -624,15 +624,21 @@ draw_bezier(DiaRenderer *self,
             int numpoints,
             Color *color)
 {
-  _bezier (self, points, numpoints, color, FALSE);
+  _bezier (self, points, numpoints, NULL, color);
 }
 static void
-fill_bezier(DiaRenderer *self, 
-            BezPoint *points,
-            int numpoints,
-            Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-  _bezier (self, points, numpoints, color, TRUE);
+  if (!fill && stroke) { /* maybe this is too clever: close path by existance of fill attribute */
+    Color transparent = { 0, };
+    _bezier (self, points, numpoints, &transparent, stroke);
+  } else {
+    _bezier (self, points, numpoints, fill, stroke);
+  }
 }
 
 static void 
@@ -744,7 +750,7 @@ drs_renderer_class_init (DrsRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   renderer_class->draw_rounded_polyline = draw_rounded_polyline;
   /* highest level functions */
diff --git a/plug-ins/libart/dialibartrenderer.c b/plug-ins/libart/dialibartrenderer.c
index 2cd7e46..d59a2fc 100644
--- a/plug-ins/libart/dialibartrenderer.c
+++ b/plug-ins/libart/dialibartrenderer.c
@@ -942,10 +942,11 @@ draw_bezier(DiaRenderer *self,
 }
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints, 
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints, 
+               Color *fill,
+               Color *stroke)
 {
   DiaLibartRenderer *renderer = DIA_LIBART_RENDERER (self);
   ArtVpath *vpath;
@@ -954,9 +955,16 @@ fill_bezier(DiaRenderer *self,
   guint32 rgba;
   double x,y;
   int i;
+  gboolean stroke_needed;
+
+  /* Only do the extra stroke if the colors are different or stroke is no hairline */
+  stroke_needed = ((!fill && stroke) || /* stroke alone */
+                  (fill && stroke && memcmp (fill, stroke, sizeof(Color)) != 0) || /* different colors */
+                  (renderer->line_width > 0) /* significant line width */);
+
+  /* we could handle it but would not draw anything */
+  g_return_if_fail (fill != NULL || stroke != NULL);
 
-  rgba = color_to_rgba(renderer, color);
-  
   bpath = art_new (ArtBpath, numpoints+1);
 
   for (i=0;i<numpoints;i++) {
@@ -1004,28 +1012,35 @@ fill_bezier(DiaRenderer *self,
   vpath = art_bez_path_to_vec(bpath, 0.25);
   art_free(bpath);
 
-  svp = art_svp_from_vpath (vpath);
-  {
-    /** We always use odd-even wind rule */
-    ArtSvpWriter *swr = art_svp_writer_rewind_new(ART_WIND_RULE_ODDEVEN);
-    ArtSVP *svp_rw;
-
-    art_svp_intersector(svp, swr);
-    svp_rw = art_svp_writer_rewind_reap(swr);
-    art_svp_free(svp);
-    svp = svp_rw;
+  if (fill) {
+    rgba = color_to_rgba(renderer, fill);
+    svp = art_svp_from_vpath (vpath);
+    {
+      /** We always use odd-even wind rule */
+      ArtSvpWriter *swr = art_svp_writer_rewind_new(ART_WIND_RULE_ODDEVEN);
+      ArtSVP *svp_rw;
+
+      art_svp_intersector(svp, swr);
+      svp_rw = art_svp_writer_rewind_reap(swr);
+      art_svp_free(svp);
+      svp = svp_rw;
+    }
+    art_rgb_svp_alpha (svp,
+                      0, 0, renderer->pixel_width, renderer->pixel_height,
+                      rgba, renderer->rgb_buffer, renderer->pixel_width*3, NULL);
+    art_svp_free( svp );
+  }
+  if (stroke && stroke_needed) {
+    rgba = color_to_rgba(renderer, stroke);
+    svp = art_svp_vpath_stroke (vpath,
+                               renderer->join_style, renderer->cap_style,
+                               renderer->line_width, 4, 0.25);
+    art_rgb_svp_alpha (svp, 0, 0,  renderer->pixel_width, renderer->pixel_height,
+                      rgba, renderer->rgb_buffer, renderer->pixel_width*3, NULL);
+    art_svp_free( svp );
   }
-  art_free( vpath );
-  
-  art_rgb_svp_alpha (svp,
-                    0, 0, 
-                    renderer->pixel_width,
-                    renderer->pixel_height,
-                    rgba,
-                    renderer->rgb_buffer, renderer->pixel_width*3,
-                    NULL);
 
-  art_svp_free( svp );
+  art_free( vpath );
 }
 
 
@@ -1521,7 +1536,7 @@ dia_libart_renderer_class_init (DiaLibartRendererClass *klass)
   renderer_class->fill_ellipse = fill_ellipse;
 
   renderer_class->draw_bezier = draw_bezier;
-  renderer_class->fill_bezier = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   renderer_class->draw_string = draw_string;
   renderer_class->draw_text_line = draw_text_line;
diff --git a/plug-ins/metapost/render_metapost.c b/plug-ins/metapost/render_metapost.c
index 04fae41..fbb03c4 100644
--- a/plug-ins/metapost/render_metapost.c
+++ b/plug-ins/metapost/render_metapost.c
@@ -199,10 +199,11 @@ static void draw_bezier(DiaRenderer *self,
                        BezPoint *points,
                        int numpoints,
                        Color *color);
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points, /* Last point must be same as first point */
-                       int numpoints,
-                       Color *color);
+static void draw_beziergon(DiaRenderer *self, 
+                          BezPoint *points, /* Last point must be same as first point */
+                          int numpoints,
+                          Color *fill,
+                          Color *stroke);
 static void draw_string(DiaRenderer *self,
                        const char *text,
                        Point *pos, Alignment alignment,
@@ -292,7 +293,7 @@ metapost_renderer_class_init (MetapostRendererClass *klass)
   renderer_class->fill_ellipse = fill_ellipse;
 
   renderer_class->draw_bezier = draw_bezier;
-  renderer_class->fill_bezier = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   renderer_class->draw_string = draw_string;
   renderer_class->draw_text = draw_text;
@@ -310,17 +311,17 @@ end_draw_op(MetapostRenderer *renderer)
     
     fprintf(renderer->file, "\n    withpen pencircle scaled %sx", 
             g_ascii_formatd(d1_buf, sizeof(d1_buf), "%5.4f", (gdouble) renderer->line_width) );
-    
+
     if (!color_equals(&renderer->color, &color_black))
         fprintf(renderer->file, "\n    withcolor (%s, %s, %s)", 
                 g_ascii_formatd(d1_buf, sizeof(d1_buf), "%5.4f", (gdouble) renderer->color.red),
                 g_ascii_formatd(d2_buf, sizeof(d2_buf), "%5.4f", (gdouble) renderer->color.green),
                 g_ascii_formatd(d3_buf, sizeof(d3_buf), "%5.4f", (gdouble) renderer->color.blue) );
-    
+
     draw_with_linestyle(renderer);
     fprintf(renderer->file, ";\n");
 }
-           
+
 static void 
 set_line_color(MetapostRenderer *renderer,Color *color)
 {
@@ -906,10 +907,11 @@ draw_bezier(DiaRenderer *self,
 
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
     gint i;
@@ -955,9 +957,16 @@ fill_bezier(DiaRenderer *self,
 
     fprintf(renderer->file,
            "  fill p withcolor (%s,%s,%s);\n",
-           mp_dtostr(red_buf, (gdouble) color->red),
-           mp_dtostr(green_buf, (gdouble) color->green),
-           mp_dtostr(blue_buf, (gdouble) color->blue) );
+           mp_dtostr(red_buf, (gdouble) fill->red),
+           mp_dtostr(green_buf, (gdouble) fill->green),
+           mp_dtostr(blue_buf, (gdouble) fill->blue) );
+
+    /* XXX: not closing as before draw_beziergon existence
+     * It should be possible to reuse the path from above to stroke again or
+     * maybe fill and stroke in one step.
+     */
+    if (stroke)
+      draw_bezier (self, points, numpoints, stroke);
 }
 
 static void
diff --git a/plug-ins/pgf/render_pgf.c b/plug-ins/pgf/render_pgf.c
index ff3c125..124f244 100644
--- a/plug-ins/pgf/render_pgf.c
+++ b/plug-ins/pgf/render_pgf.c
@@ -136,10 +136,11 @@ static void draw_bezier(DiaRenderer *self,
                        BezPoint *points,
                        int numpoints,
                        Color *color);
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points, /* Last point must be same as first point */
-                       int numpoints,
-                       Color *color);
+static void draw_beziergon(DiaRenderer *self, 
+                          BezPoint *points,
+                          int numpoints,
+                          Color *fill,
+                          Color *stroke);
 static void draw_string(DiaRenderer *self,
                        const char *text,
                        Point *pos, Alignment alignment,
@@ -272,7 +273,7 @@ pgf_renderer_class_init (PgfRendererClass *klass)
   renderer_class->fill_ellipse = fill_ellipse;
 
   renderer_class->draw_bezier = draw_bezier;
-  renderer_class->fill_bezier = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
 /* to keep the dia arrows instead of the native PGF ones, comment out this block of commands */
   orig_draw_line_with_arrows = renderer_class->draw_line_with_arrows;
@@ -828,10 +829,10 @@ pgf_bezier(PgfRenderer *renderer,
                    pgf_dtostr(p3y_buf,points[i].p3.y) );
            break;
        }
-    
+
     if (filled)
        fprintf(renderer->file, "\\pgfusepath{fill}\n");
-       
+
 /*     fill[fillstyle=solid,fillcolor=diafillcolor,linecolor=diafillcolor]}\n"); */
     else
        fprintf(renderer->file, "\\pgfusepath{stroke}\n");
@@ -851,14 +852,19 @@ draw_bezier(DiaRenderer *self,
 
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
     PgfRenderer *renderer = PGF_RENDERER(self);
 
-    pgf_bezier(renderer,points,numpoints,color,TRUE);
+    /* XXX: still not closing the path */
+    if (fill)
+       pgf_bezier(renderer,points,numpoints,fill,TRUE);
+    if (stroke)
+       pgf_bezier(renderer,points,numpoints,stroke,FALSE);
 }
 
 static int 
diff --git a/plug-ins/postscript/diapsrenderer.c b/plug-ins/postscript/diapsrenderer.c
index c2dd07e..5fd8d31 100644
--- a/plug-ins/postscript/diapsrenderer.c
+++ b/plug-ins/postscript/diapsrenderer.c
@@ -595,13 +595,18 @@ draw_bezier(DiaRenderer *self,
 }
 
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points, /* Last point must be same as first point */
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
   DiaPsRenderer *renderer = DIA_PS_RENDERER(self);
-  psrenderer_bezier(renderer, points, numpoints, color, TRUE);
+  if (fill)
+    psrenderer_bezier(renderer, points, numpoints, fill, TRUE);
+  /* XXX: still not closing the path */
+  if (stroke)
+    psrenderer_bezier(renderer, points, numpoints, stroke, TRUE);
 }
 
 static char*
@@ -1044,7 +1049,7 @@ dia_ps_renderer_class_init (DiaPsRendererClass *klass)
 
   /* medium level functions */
   renderer_class->draw_bezier  = draw_bezier;
-  renderer_class->fill_bezier  = fill_bezier;
+  renderer_class->draw_beziergon  = draw_beziergon;
   renderer_class->draw_rect = draw_rect;
   renderer_class->fill_rect = fill_rect;
   renderer_class->draw_polyline  = draw_polyline;
diff --git a/plug-ins/postscript/render_eps.c b/plug-ins/postscript/render_eps.c
index 5cd8a58..42d8f6a 100644
--- a/plug-ins/postscript/render_eps.c
+++ b/plug-ins/postscript/render_eps.c
@@ -154,7 +154,7 @@ new_psprint_renderer(DiagramData *dia, FILE *file)
   renderer = g_object_new (DIA_TYPE_PS_RENDERER, NULL);
 #endif
   renderer->file = file;
-  renderer->pstype = PSTYPE_PS;;
+  renderer->pstype = PSTYPE_PS;
 
   return DIA_RENDERER(renderer);
 }
diff --git a/plug-ins/pstricks/render_pstricks.c b/plug-ins/pstricks/render_pstricks.c
index 47876f7..afe10dc 100644
--- a/plug-ins/pstricks/render_pstricks.c
+++ b/plug-ins/pstricks/render_pstricks.c
@@ -113,10 +113,11 @@ static void draw_bezier(DiaRenderer *self,
                        BezPoint *points,
                        int numpoints,
                        Color *color);
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points, /* Last point must be same as first point */
-                       int numpoints,
-                       Color *color);
+static void draw_beziergon(DiaRenderer *self, 
+                          BezPoint *points,
+                          int numpoints,
+                          Color *fill,
+                          Color *stroke);
 static void draw_string(DiaRenderer *self,
                        const char *text,
                        Point *pos, Alignment alignment,
@@ -201,7 +202,7 @@ pstricks_renderer_class_init (PstricksRendererClass *klass)
   renderer_class->fill_ellipse = fill_ellipse;
 
   renderer_class->draw_bezier = draw_bezier;
-  renderer_class->fill_bezier = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   renderer_class->draw_string = draw_string;
 
@@ -451,6 +452,9 @@ pstricks_polygon(PstricksRenderer *renderer,
 
     set_line_color(renderer, line_color);
 
+    /* The graphics objects all have a starred version (e.g., \psframe*) which
+     * draws a solid object whose color is linecolor. [pstricks-doc.pdf p7]
+     */
     fprintf(renderer->file, "\\pspolygon%s(%s,%s)",
            (filled?"*":""),
            pstricks_dtostr(px_buf,points[0].x),
@@ -702,16 +706,23 @@ draw_bezier(DiaRenderer *self,
 }
 
 
-
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *color)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
     PstricksRenderer *renderer = PSTRICKS_RENDERER(self);
 
-    pstricks_bezier(renderer,points,numpoints,color,TRUE);
+    /* XXX: it should be easy to fill and stroke in one step using
+     * fillcolor and linecolor at the same time
+     */
+    if (fill)
+       pstricks_bezier(renderer,points,numpoints,fill,TRUE);
+    /* XXX: still not closing the path */
+    if (stroke)
+       pstricks_bezier(renderer,points,numpoints,stroke,FALSE);
 }
 
 /* Do we really want to do this?  What if the text is intended as 
diff --git a/plug-ins/python/diasvg.py b/plug-ins/python/diasvg.py
index a02bb7d..17df5c1 100644
--- a/plug-ins/python/diasvg.py
+++ b/plug-ins/python/diasvg.py
@@ -167,9 +167,7 @@ class SvgRenderer :
        def fill_ellipse (self, center, width, height, color) :
                self.f.write('<ellipse cx="%.3f" cy="%.3f" rx="%.3f" ry="%.3f" fill="%s" stroke="none"  />' \
                                        % (center.x, center.y, width / 2, height / 2, self._rgb(color)))
-       def draw_bezier (self, bezpoints, color) :
-               self.f.write('<path stroke="%s" fill="none" stroke-width="%.3f" %s d="' \
-                                       % (self._rgb(color), self.line_width, self._stroke_style()))
+       def _bezier (self, bezpoints) :
                for bp in bezpoints :
                        if bp.type == 0 : # BEZ_MOVE_TO
                                self.f.write('M %.3f,%.3f ' % (bp.p1.x, bp.p1.y))
@@ -180,21 +178,22 @@ class SvgRenderer :
                                        % (bp.p1.x, bp.p1.y, bp.p2.x, bp.p2.y, bp.p3.x, bp.p3.y))
                        else :
                                dia.message(2, "Invalid BezPoint type (%d)" * bp.type)
+       def draw_bezier (self, bezpoints, color) :
+               self.f.write('<path stroke="%s" fill="none" stroke-width="%.3f" %s d="' \
+                                       % (self._rgb(color), self.line_width, self._stroke_style()))
+               self._bezier (bezpoints)
                self.f.write('"/>\n')
+       # old version, wont be called anymore with newer Dia
        def fill_bezier (self, bezpoints, color) :
                self.f.write('<path stroke="none" fill="%s" stroke-width="%.3f" d="' \
                                        % (self._rgb(color), self.line_width))
-               for bp in bezpoints :
-                       if bp.type == 0 : # BEZ_MOVE_TO
-                               self.f.write('M %.3f,%.3f ' % (bp.p1.x, bp.p1.y))
-                       elif bp.type == 1 : # BEZ_LINE_TO
-                               self.f.write('L %.3f,%.3f ' % (bp.p1.x, bp.p1.y))
-                       elif bp.type == 2 : # BEZ_CURVE_TO
-                               self.f.write ('C %.3f,%.3f %.3f,%.3f %.3f,%.3f ' \
-                                       % (bp.p1.x, bp.p1.y, bp.p2.x, bp.p2.y, bp.p3.x, bp.p3.y))
-                       else :
-                               dia.message(2, "Invalid BezPoint type (%d)" * bp.type)
+               self._bezier (bezpoints)
                self.f.write('"/>\n')
+       def draw_beziergon (self, bezpoints, fill, stroke) :
+               self.f.write('<path stroke="%s" fill="%s" stroke-width="%.3f" d="' \
+                                       % (self._rgb(stroke), self._rgb(fill), self.line_width))
+               self._bezier (bezpoints)
+               self.f.write('z"/>\n')
        def draw_string (self, text, pos, alignment, color) :
                if len(text) < 1 :
                        return # shouldn'this be done at the higher level 
@@ -217,6 +216,8 @@ class SvgRenderer :
                return text
        def _rgb(self, color) :
                # given a dia color convert to svg color string
+               if not color :
+                       return "none"
                rgb = "#%02X%02X%02X" % (int(255 * color.red), int(color.green * 255), int(color.blue * 255))
                return rgb
        def _stroke_style(self) :
diff --git a/plug-ins/python/pydia-render.c b/plug-ins/python/pydia-render.c
index f8a235b..42d7982 100644
--- a/plug-ins/python/pydia-render.c
+++ b/plug-ins/python/pydia-render.c
@@ -1010,6 +1010,7 @@ draw_bezier(DiaRenderer *renderer,
   }
 }
 
+/* kept for backward compatibility, not any longer in the renderer interface */
 static void
 fill_bezier(DiaRenderer *renderer, 
            BezPoint *points, /* Last point must be same as first point */
@@ -1038,7 +1039,58 @@ fill_bezier(DiaRenderer *renderer,
   else { /* member optional */
     PyErr_Clear();
     /* XXX: implementing the same fallback as DiaRenderer would do */
-    DIA_RENDERER_CLASS (parent_class)->fill_bezier (renderer, points, num_points, colour);
+    DIA_RENDERER_CLASS (parent_class)->draw_beziergon (renderer, points, num_points, colour, NULL);
+  }
+}
+
+/*!
+ * \brief Fill and/or stroke a closed path
+ * \memberof _DiaPyRenderer
+ */
+static void
+draw_beziergon (DiaRenderer *renderer,
+               BezPoint *points,
+               int num_points,
+               Color *fill,
+               Color *stroke)
+{
+  PyObject *func, *res, *arg, *self = PYDIA_RENDERER (renderer);
+
+  func = PyObject_GetAttrString (self, "draw_beziergon");
+  if (func && PyCallable_Check(func)) {
+    PyObject *obt = PyDiaBezPointTuple_New (points, num_points);
+    PyObject *fill_po;
+    PyObject *stroke_po;
+    Py_INCREF(self);
+    Py_INCREF(func);
+    /* we have to provide a Python object even if there is no color */
+    if (fill)
+      fill_po = PyDiaColor_New (fill);
+    else
+      Py_INCREF(Py_None), fill_po = Py_None;
+    if (stroke)
+      stroke_po = PyDiaColor_New (stroke);
+    else
+      Py_INCREF(Py_None), stroke_po = Py_None;
+
+    arg = Py_BuildValue ("(OOO)", obt, fill_po, stroke_po);
+    if (arg) {
+      res = PyEval_CallObject (func, arg);
+      ON_RES(res, FALSE);
+    }
+    Py_XDECREF (arg);
+    Py_XDECREF (obt);
+    Py_XDECREF (fill_po);
+    Py_XDECREF (stroke_po);
+    Py_DECREF(func);
+    Py_DECREF(self);
+  } else { /* member optional */
+    PyErr_Clear();
+    /* PyDia only backward compatibility */
+    if (fill)
+      fill_bezier (renderer, points, num_points, fill);
+    if (stroke) /* XXX: still not closing */
+      draw_bezier (renderer, points, num_points, stroke);
   }
 }
 
@@ -1269,7 +1321,7 @@ dia_py_renderer_class_init (DiaPyRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   /* highest level functions */
   renderer_class->draw_rounded_rect = draw_rounded_rect;
diff --git a/plug-ins/vdx/vdx-export.c b/plug-ins/vdx/vdx-export.c
index 812a3ba..de19208 100644
--- a/plug-ins/vdx/vdx-export.c
+++ b/plug-ins/vdx/vdx-export.c
@@ -247,19 +247,14 @@ vdx_renderer_class_init (VDXRendererClass *klass)
 
   /* Until we have NURBS, let Dia use lines */
   /* renderer_class->draw_bezier = draw_bezier; */
-  /* renderer_class->fill_bezier = fill_bezier; */
+  /* renderer_class->draw_beziergon = draw_beziergon; */
   /* renderer_class->draw_bezier_with_arrows = draw_bezier_with_arrows; */
 
   renderer_class->draw_string = draw_string;
 
   renderer_class->draw_image = draw_image;
 
-  /* Believe these are never used or are unnecessary */
-  /* renderer_class->draw_line_with_arrows = draw_line_with_arrows; */
-  /* renderer_class->draw_polyline_with_arrows = draw_polyline_with_arrows; */
-  /* renderer_class->draw_arc_with_arrows = draw_arc_with_arrows; */
-  /* renderer_class->draw_object = draw_object; */
-
+  /* Further high level methods not required (or desired) */
 }
 
 /** Initialises VDXrenderer
@@ -2084,18 +2079,19 @@ static void draw_bezier_with_arrows(DiaRenderer *self,
     g_debug("draw_bezier_with_arrows (TODO)");
 }
 
-/** Render a Dia filled Bezier
+/** Render a Dia closed Bezier
  * @param self a renderer
  * @param points list of Bezier points (last = first)
  * @param numpoints number of points
  * @param color line colour
  * @todo Not done yet - either convert to arcs or NURBS (Visio 2003)
  */
-
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points,
-                       int numpoints,
-                       Color *color)
+static void
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
     VDXRenderer *renderer = VDX_RENDERER(self);
     
@@ -2105,7 +2101,7 @@ static void fill_bezier(DiaRenderer *self,
         return;
     }
 
-    g_debug("fill_bezier (TODO)");
+    g_debug("draw_beziergon (TODO)");
 }
 
 /** Render a Dia object
diff --git a/plug-ins/wmf/wmf.cpp b/plug-ins/wmf/wmf.cpp
index 91a618c..93194fa 100644
--- a/plug-ins/wmf/wmf.cpp
+++ b/plug-ins/wmf/wmf.cpp
@@ -878,11 +878,12 @@ fill_ellipse(DiaRenderer *self,
 
 #ifndef DIRECT_WMF
 static void
-_bezier (DiaRenderer *self, 
-           BezPoint *points,
-           int       numpoints,
-           Color    *colour,
-           gboolean  fill)
+_bezier (DiaRenderer *self,
+        BezPoint *points,
+        int       numpoints,
+        Color    *colour,
+        gboolean  fill,
+        gboolean  closed)
 {
     WmfRenderer *renderer = WMF_RENDERER (self);
     W32::HGDIOBJ hBrush, hBrOld;
@@ -921,6 +922,8 @@ _bezier (DiaRenderer *self,
          break;
        }
     }
+    if (closed)
+        W32::CloseFigure (renderer->hFileDC);
     W32::EndPath (renderer->hFileDC);
     if (fill) {
         W32::FillPath (renderer->hFileDC);
@@ -941,7 +944,7 @@ draw_bezier(DiaRenderer *self,
            Color *colour)
 {
 #ifndef DIRECT_WMF
-    _bezier(self, points, numpoints, colour, FALSE);
+    _bezier(self, points, numpoints, colour, FALSE, FALSE);
 #else
     WmfRenderer *renderer = WMF_RENDERER (self);
     W32::HPEN    hPen;
@@ -999,12 +1002,16 @@ draw_bezier(DiaRenderer *self,
 #ifndef DIRECT_WMF
 /* not defined in compatibility layer */
 static void
-fill_bezier(DiaRenderer *self, 
-           BezPoint *points, /* Last point must be same as first point */
-           int numpoints,
-           Color *colour)
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points, /* Last point must be same as first point */
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
-    _bezier(self, points, numpoints, colour, TRUE);
+    if (fill)
+       _bezier(self, points, numpoints, fill, TRUE, TRUE);
+    if (stroke)
+       _bezier(self, points, numpoints, stroke, FALSE, TRUE);
 }
 #endif
 
@@ -1312,7 +1319,7 @@ wmf_renderer_class_init (WmfRendererClass *klass)
 
   renderer_class->draw_bezier   = draw_bezier;
 #ifndef DIRECT_WMF
-  renderer_class->fill_bezier   = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 #endif
 #ifndef HAVE_LIBEMF
   renderer_class->draw_rounded_rect = draw_rounded_rect;
diff --git a/plug-ins/wpg/wpg-import.c b/plug-ins/wpg/wpg-import.c
index 9c8daa2..6ab53ae 100644
--- a/plug-ins/wpg/wpg-import.c
+++ b/plug-ins/wpg/wpg-import.c
@@ -188,12 +188,13 @@ _do_bezier (WpgImportRenderer *ren, WPGPoint *pts, int iNum)
     bps[i].p3.x =        (gint16)pts[i*3  ].x  / WPU_PER_DCM;
     bps[i].p3.y = (ofs - (gint16)pts[i*3  ].y) / WPU_PER_DCM;
   }
+  /* XXX: should we fold this calls into one? What's closing a WPG PolyCurve? */
   if (ren->LineAttr.Type != WPG_LA_NONE)
     DIA_RENDERER_GET_CLASS(ren)->draw_bezier (DIA_RENDERER(ren),
                                              bps, num_points, &ren->stroke);
   if (ren->FillAttr.Type != WPG_FA_HOLLOW)
-    DIA_RENDERER_GET_CLASS(ren)->fill_bezier (DIA_RENDERER(ren),
-                                             bps, num_points, &ren->fill);
+    DIA_RENDERER_GET_CLASS(ren)->draw_beziergon (DIA_RENDERER(ren),
+                                                bps, num_points, &ren->fill, NULL);
 }
 
 /*
diff --git a/plug-ins/wpg/wpg.c b/plug-ins/wpg/wpg.c
index 523bf28..da2d986 100644
--- a/plug-ins/wpg/wpg.c
+++ b/plug-ins/wpg/wpg.c
@@ -769,23 +769,35 @@ draw_bezier(DiaRenderer *self,
   g_free(pts);
 }
 
-/* Use fallback from base class until another program can
- * actually correctly show the filled Polycurve created
- * by Dia (our own import can).
- */
-G_GNUC_UNUSED static void
-fill_bezier(DiaRenderer *self, 
-            BezPoint *points,
-            int numpoints,
-            Color *colour)
+static gpointer parent_class = NULL;
+
+static void
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke)
 {
   WpgRenderer *renderer = WPG_RENDERER (self);
 
-  DIAG_NOTE(g_message("fill_beziez %d points", numpoints));
+  DIAG_NOTE(g_message("draw_beziezgon %d points", numpoints));
 
-  WriteFillAttr(renderer, colour, TRUE);
-  draw_bezier (self, points, numpoints, colour);
-  WriteFillAttr(renderer, colour, FALSE);
+#if 1
+  /* Use fallback from base class until another program can
+   * actually correctly show the filled Polycurve created
+   * by Dia (our own import can).
+   */
+  if (fill)
+    DIA_RENDERER_CLASS(parent_class)->draw_beziergon (self, points, numpoints, fill, NULL);
+#else
+  if (fill) {
+    WriteFillAttr(renderer, fill, TRUE);
+    draw_bezier (self, points, numpoints, fill);
+    WriteFillAttr(renderer, fill, FALSE);
+  }
+#endif
+  if (stroke) /* XXX: still not closing the path */
+    draw_bezier (self, points, numpoints, stroke);
 }
 static void
 draw_string(DiaRenderer *self,
@@ -960,8 +972,6 @@ draw_image(DiaRenderer *self,
 /* gobject boiler plate */
 static void wpg_renderer_class_init (WpgRendererClass *klass);
 
-static gpointer parent_class = NULL;
-
 GType
 wpg_renderer_get_type (void)
 {
@@ -1043,9 +1053,7 @@ wpg_renderer_class_init (WpgRendererClass *klass)
   renderer_class->draw_polygon   = draw_polygon;
 
   renderer_class->draw_bezier   = draw_bezier;
-#if 0 /* use fallback from base class ... */
-  renderer_class->fill_bezier   = fill_bezier;
-#endif
+  renderer_class->draw_beziergon = draw_beziergon;
 }
 
 /* dia export funtion */
diff --git a/plug-ins/xfig/xfig-export.c b/plug-ins/xfig/xfig-export.c
index 22d8826..0eeb342 100644
--- a/plug-ins/xfig/xfig-export.c
+++ b/plug-ins/xfig/xfig-export.c
@@ -178,10 +178,11 @@ static void draw_bezier_with_arrows(DiaRenderer *self,
                                    Color *colour,
                                    Arrow *start_arrow,
                                    Arrow *end_arrow);
-static void fill_bezier(DiaRenderer *self, 
-                       BezPoint *points, /* Last point must be same as first point */
-                       int numpoints,
-                       Color *colour);
+static void draw_beziergon(DiaRenderer *self, 
+                          BezPoint *points, /* Last point must be same as first point */
+                          int numpoints,
+                          Color *fill,
+                          Color *stroke);
 static void draw_string(DiaRenderer *self,
                        const char *text,
                        Point *pos, Alignment alignment,
@@ -269,7 +270,7 @@ xfig_renderer_class_init (XfigRendererClass *klass)
   renderer_class->fill_ellipse = fill_ellipse;
 
   renderer_class->draw_bezier = draw_bezier;
-  renderer_class->fill_bezier = fill_bezier;
+  renderer_class->draw_beziergon = draw_beziergon;
 
   renderer_class->draw_string = draw_string;
 
@@ -1075,19 +1076,23 @@ draw_bezier_with_arrows(DiaRenderer *self,
 }
 
 static void 
-fill_bezier(DiaRenderer *self, 
-            BezPoint *points, /* Last point must be same as first point */
-            int numpoints,
-            Color *color) 
+draw_beziergon (DiaRenderer *self, 
+               BezPoint *points,
+               int numpoints,
+               Color *fill,
+               Color *stroke) 
 {
   XfigRenderer *renderer = XFIG_RENDERER(self);
 
   if (renderer->color_pass) {
-    figCheckColor(renderer, color);
+    if (fill)
+      figCheckColor(renderer, fill);
+    if (stroke)
+      figCheckColor(renderer, stroke);
     return;
   }
 
-  DIA_RENDERER_CLASS(parent_class)->fill_bezier(self, points, numpoints, color);
+  DIA_RENDERER_CLASS(parent_class)->draw_beziergon(self, points, numpoints, fill, stroke);
 }
 
 static void 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]