From: Cristy Date: Sun, 22 Apr 2018 12:16:54 +0000 (-0400) Subject: ... X-Git-Tag: 7.0.7-29~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a0763faf3dbe06425417611504119ff5478f8d2;p=imagemagick ... --- diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 94dc44d2e..8db2305b5 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -1691,7 +1691,7 @@ static size_t GetEllipseCoordinates(const PointInfo start,const PointInfo stop, return((size_t) floor((angle.y-angle.x)/step+0.5)+3); } -static char *GetNodeByID(const char *primitive,const char *id) +static char *GetGroupByURL(const char *primitive,const char *url) { char *token; @@ -1758,7 +1758,7 @@ static char *GetNodeByID(const char *primitive,const char *id) if (*q == '"') { GetNextToken(q,&q,extent,token); - if (LocaleCompare(id,token) == 0) + if (LocaleCompare(url,token) == 0) { /* Start of group by ID. @@ -1901,7 +1901,8 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, defsDepth, j, k, - n; + n, + symbolDepth; StopInfo *stops; @@ -1968,6 +1969,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) return(MagickFalse); defsDepth=0; + symbolDepth=0; status=MagickTrue; for (q=primitive; *q != '\0'; ) { @@ -2478,6 +2480,13 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, } if (LocaleCompare("pattern",token) == 0) break; + if (LocaleCompare("symbol",token) == 0) + { + symbolDepth--; + graphic_context[n]->render=symbolDepth > 0 ? MagickFalse : + MagickTrue; + break; + } status=MagickFalse; break; } @@ -2509,6 +2518,13 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, GetNextToken(q,&q,extent,token); break; } + if (LocaleCompare("defs",token) == 0) + { + defsDepth++; + graphic_context[n]->render=defsDepth > 0 ? MagickFalse : + MagickTrue; + break; + } if (LocaleCompare("gradient",token) == 0) { char @@ -2593,6 +2609,24 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, GetNextToken(q,&q,extent,token); break; } + if (LocaleCompare("graphic-context",token) == 0) + { + n++; + graphic_context=(DrawInfo **) ResizeQuantumMemory( + graphic_context,(size_t) (n+1),sizeof(*graphic_context)); + if (graphic_context == (DrawInfo **) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'", + image->filename); + break; + } + graphic_context[n]=CloneDrawInfo((ImageInfo *) NULL, + graphic_context[n-1]); + if (*q == '"') + GetNextToken(q,&q,extent,token); + break; + } if (LocaleCompare("pattern",token) == 0) { char @@ -2656,28 +2690,10 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, GetNextToken(q,&q,extent,token); break; } - if (LocaleCompare("graphic-context",token) == 0) - { - n++; - graphic_context=(DrawInfo **) ResizeQuantumMemory( - graphic_context,(size_t) (n+1),sizeof(*graphic_context)); - if (graphic_context == (DrawInfo **) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - image->filename); - break; - } - graphic_context[n]=CloneDrawInfo((ImageInfo *) NULL, - graphic_context[n-1]); - if (*q == '"') - GetNextToken(q,&q,extent,token); - break; - } - if (LocaleCompare("defs",token) == 0) + if (LocaleCompare("symbol",token) == 0) { - defsDepth++; - graphic_context[n]->render=defsDepth > 0 ? MagickFalse : + symbolDepth++; + graphic_context[n]->render=symbolDepth > 0 ? MagickFalse : MagickTrue; break; } @@ -3000,21 +3016,21 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (LocaleCompare("use",keyword) == 0) { char - *node; + *group; /* Take a node from within the MVG document, and duplicate it here. */ GetNextToken(q,&q,extent,token); - node=GetNodeByID(primitive,token); - if (node != (char *) NULL) + group=GetGroupByURL(primitive,token); + if (group != (char *) NULL) { DrawInfo *clone_info; clone_info=CloneDrawInfo((ImageInfo *) NULL,graphic_context[n]); - (void) CloneString(&clone_info->primitive,node); - node=DestroyString(node); + (void) CloneString(&clone_info->primitive,group); + group=DestroyString(group); status=DrawImage(image,clone_info,exception); clone_info=DestroyDrawInfo(clone_info); } diff --git a/coders/svg.c b/coders/svg.c index 8c2e7502b..482dd7a7a 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -1129,6 +1129,11 @@ static void SVGStartElement(void *context,const xmlChar *name, case 'S': case 's': { + if (LocaleCompare((const char *) name,"symbol") == 0) + { + (void) FormatLocaleFile(svg_info->file,"push symbol\n"); + break; + } if (LocaleCompare((const char *) name,"svg") == 0) { PushGraphicContext(id); @@ -1532,10 +1537,7 @@ static void SVGStartElement(void *context,const xmlChar *name, } if (LocaleCompare(keyword,"href") == 0) { - if (*value != '#') - (void) CloneString(&svg_info->url,value); - else - (void) CloneString(&svg_info->url,value+1); + (void) CloneString(&svg_info->url,value); break; } break; @@ -2218,10 +2220,7 @@ static void SVGStartElement(void *context,const xmlChar *name, } if (LocaleCompare(keyword,"xlink:href") == 0) { - if (*value != '#') - (void) CloneString(&svg_info->url,value); - else - (void) CloneString(&svg_info->url,value+1); + (void) CloneString(&svg_info->url,value); break; } if (LocaleCompare(keyword,"x1") == 0) @@ -2525,6 +2524,11 @@ static void SVGEndElement(void *context,const xmlChar *name) svg_info->stop_color,svg_info->offset); break; } + if (LocaleCompare((const char *) name,"symbol") == 0) + { + (void) FormatLocaleFile(svg_info->file,"pop symbol\n"); + break; + } if (LocaleCompare((const char *) name,"svg") == 0) { (void) FormatLocaleFile(svg_info->file,"pop graphic-context\n"); @@ -2599,7 +2603,8 @@ static void SVGEndElement(void *context,const xmlChar *name) if ((svg_info->bounds.x != 0.0) || (svg_info->bounds.y != 0.0)) (void) FormatLocaleFile(svg_info->file,"translate %g,%g\n", svg_info->bounds.x,svg_info->bounds.y); - (void) FormatLocaleFile(svg_info->file,"use \"%s\"\n",svg_info->url); + (void) FormatLocaleFile(svg_info->file,"use \"url(%s)\"\n", + svg_info->url); (void) FormatLocaleFile(svg_info->file,"pop graphic-context\n"); break; } @@ -4224,8 +4229,14 @@ static MagickBooleanType WriteSVGImage(const ImageInfo *image_info,Image *image, (void) WriteBlobString(image,"\n"); break; } - if (LocaleCompare("defs",token) == 0) - (void) WriteBlobString(image,"\n"); + if (LocaleCompare("symbol",token) == 0) + { + (void) WriteBlobString(image,"\n"); + break; + } + if ((LocaleCompare("defs",token) == 0) || + (LocaleCompare("symbol",token) == 0)) + (void) WriteBlobString(image,"\n"); break; } if (LocaleCompare("push",keyword) == 0) @@ -4328,6 +4339,11 @@ static MagickBooleanType WriteSVGImage(const ImageInfo *image_info,Image *image, (void) WriteBlobString(image,message); break; } + if (LocaleCompare("symbol",token) == 0) + { + (void) WriteBlobString(image,"\n"); + break; + } break; } status=MagickFalse;