From: Cristy Date: Sat, 7 Jul 2018 13:00:08 +0000 (-0400) Subject: Improve SVG support for tspan element X-Git-Tag: 7.0.8-6~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2667e84f69b7f1ef541c334097a412466118da56;p=imagemagick Improve SVG support for tspan element --- diff --git a/ChangeLog b/ChangeLog index dda99664d..1ea4bc3dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2018-07-06 7.0.8-6 Cristy + * Improve SVG support for tspan element. + 2018-07-04 7.0.8-5 Cristy * Release ImageMagick version 7.0.8-5, GIT revision 14514:bba545bbb:20180704. diff --git a/MagickCore/draw.c b/MagickCore/draw.c index 97518d7d1..1e29d7958 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -2508,9 +2508,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, } token=AcquireString(primitive); extent=strlen(token)+MagickPathExtent; - cursor=0.0; defsDepth=0; symbolDepth=0; + cursor=0.0; macros=GetMVGMacros(primitive); status=MagickTrue; for (q=primitive; *q != '\0'; ) @@ -2577,7 +2577,6 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, affine.ty=StringToDouble(token,&next_token); if (token == next_token) ThrowPointExpectedException(token,exception); - cursor=0.0; break; } if (LocaleCompare("alpha",keyword) == 0) @@ -3632,7 +3631,6 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, if (LocaleCompare("text",keyword) == 0) { primitive_type=TextPrimitive; - /* affine.tx+=cursor; */ break; } if (LocaleCompare("text-align",keyword) == 0) @@ -4167,6 +4165,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, } case TextPrimitive: { + char + geometry[MagickPathExtent]; + DrawInfo *clone_info; @@ -4185,8 +4186,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info, Compute text cursor offset. */ clone_info=CloneDrawInfo((ImageInfo *) NULL,graphic_context[n]); - if (clone_info->density != (char *) NULL) - clone_info->density=DestroyString(clone_info->density); + primitive_info->point.x+=cursor; + (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f", + primitive_info->point.x,primitive_info->point.y); clone_info->render=MagickFalse; clone_info->text=AcquireString(token); (void) ConcatenateString(&clone_info->text," "); diff --git a/coders/mvg.c b/coders/mvg.c index ba8eaea50..55afec6fd 100644 --- a/coders/mvg.c +++ b/coders/mvg.c @@ -185,6 +185,8 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception) if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); + if (draw_info->density != (char *) NULL) + draw_info->density=DestroyString(draw_info->density); draw_info->affine.sx=image->resolution.x == 0.0 ? 1.0 : image->resolution.x/ 96.0; draw_info->affine.sy=image->resolution.y == 0.0 ? 1.0 : image->resolution.y/ diff --git a/coders/svg.c b/coders/svg.c index 3237b85ed..482989b86 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -818,7 +818,12 @@ static void SVGProcessStyleElement(void *context,const xmlChar *name, if (sscanf(value,"%2048s %2048s %2048s",style,size,family) != 3) break; - (void) FormatLocaleFile(svg_info->file,"font-style \"%s\"\n",style); + if (GetUserSpaceCoordinateValue(svg_info,0,style) == 0) + (void) FormatLocaleFile(svg_info->file,"font-style \"%s\"\n", + style); + else + if (sscanf(value,"%2048s %2048s",size,family) != 2) + break; (void) FormatLocaleFile(svg_info->file,"font-size \"%s\"\n",size); (void) FormatLocaleFile(svg_info->file,"font-family \"%s\"\n", family); @@ -1462,6 +1467,7 @@ static void SVGStartElement(void *context,const xmlChar *name, if (LocaleCompare((const char *) name,"text") == 0) { PushGraphicContext(id); + (void) FormatLocaleFile(svg_info->file,"class \"text\"\n"); (void) FormatLocaleFile(svg_info->file,"translate %g,%g\n", svg_info->bounds.x,svg_info->bounds.y); svg_info->center.x=svg_info->bounds.x; @@ -2675,7 +2681,6 @@ static void SVGEndElement(void *context,const xmlChar *name) char *text; - (void) FormatLocaleFile(svg_info->file,"class \"text\"\n"); text=EscapeString(svg_info->text,'\''); (void) FormatLocaleFile(svg_info->file,"text 0,0 \"%s\"\n",text); text=DestroyString(text); @@ -2693,6 +2698,7 @@ static void SVGEndElement(void *context,const xmlChar *name) char *text; + (void) FormatLocaleFile(svg_info->file,"class \"tspan\"\n"); text=EscapeString(svg_info->text,'\''); (void) FormatLocaleFile(svg_info->file,"text %g,%g \"%s\"\n", svg_info->bounds.x-svg_info->center.x,svg_info->bounds.y- @@ -3510,8 +3516,6 @@ static Image *ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception) image=(Image *) NULL; read_info=CloneImageInfo(image_info); SetImageInfoBlob(read_info,(void *) NULL,0); - if (read_info->density != (char *) NULL) - read_info->density=DestroyString(read_info->density); (void) FormatLocaleString(read_info->filename,MagickPathExtent,"mvg:%s", filename); image=ReadImage(read_info,exception);