From d46619a310dd04066cc117e904b84785d1a0cd51 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Mon, 13 Apr 2009 00:17:20 +0200 Subject: [PATCH] pdf2swf: fixed polygon rendering of closed strokes --- lib/gfxpoly.c | 12 ++++++++++++ lib/pdf/GFXOutputDev.cc | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/lib/gfxpoly.c b/lib/gfxpoly.c index 65a65b7..a408618 100644 --- a/lib/gfxpoly.c +++ b/lib/gfxpoly.c @@ -384,11 +384,13 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) pos = 0; l2 = line; + int lastmove=-1; while(l2) { if(l2->type == gfx_moveTo) { vec[pos].code = ART_MOVETO_OPEN; vec[pos].x = l2->x; vec[pos].y = l2->y; + lastmove=pos; pos++; assert(pos<=len); } else if(l2->type == gfx_lineTo) { @@ -413,6 +415,16 @@ static ArtVpath* gfxline_to_ArtVpath(gfxline_t*line, char fill) } x = l2->x; y = l2->y; + + /* let closed line segments start w/ MOVETO instead of MOVETO_OPEN */ + if(lastmove>=0 && l2->type!=gfx_moveTo && (!l2->next || l2->next->type == gfx_moveTo)) { + if(vec[lastmove].x == l2->x && + vec[lastmove].y == l2->y) { + assert(vec[lastmove].code == ART_MOVETO_OPEN); + vec[lastmove].code = ART_MOVETO; + } + } + l2 = l2->next; } vec[pos++].code = ART_END; diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 7bd0860..b0d1169 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -791,6 +791,31 @@ void dump_outline(gfxline_t*line) } } +void gfxPath_dump(GfxPath*path) +{ + int num = path->getNumSubpaths(); + int t; + int cpos=0; + for(t = 0; t < num; t++) { + GfxSubpath *subpath = path->getSubpath(t); + int subnum = subpath->getNumPoints(); + int s; + for(s=0;sgetX(s); + double y=subpath->getY(s); + if(s==0 && !subpath->getCurve(s)) { + printf("M %f %f\n", x, y); + } else if(s==0 && subpath->getCurve(s)) { + printf("E %f %f\n", x, y); + } else if(subpath->getCurve(s)) { + printf("C %f %f\n", x, y); + } else { + printf("T %f %f\n", x, y); + } + } + } +} + gfxline_t* GFXOutputDev::gfxPath_to_gfxline(GfxState*state, GfxPath*path, int closed, int user_movex, int user_movey) { int num = path->getNumSubpaths(); -- 1.7.10.4