]> granicus.if.org Git - imagemagick/commitdiff
Improve SVG support for tspan element
authorCristy <urban-warrior@imagemagick.org>
Sat, 7 Jul 2018 13:00:08 +0000 (09:00 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 7 Jul 2018 13:00:08 +0000 (09:00 -0400)
ChangeLog
MagickCore/draw.c
coders/mvg.c
coders/svg.c

index dda99664d8ade04d64d52763952be897c96a1803..1ea4bc3dd1759e709585301629a08e50a840b30e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2018-07-06  7.0.8-6 Cristy  <quetzlzacatenango@image...>
+  * Improve SVG support for tspan element.
+
 2018-07-04  7.0.8-5 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-5, GIT revision 14514:bba545bbb:20180704.
 
index 97518d7d1a1c824e000ebee26022221bad799bc3..1e29d7958e9396a3d29ff7d7683065e7c82be8a5 100644 (file)
@@ -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," ");
index ba8eaea50854e5b91d0f72980a0ccf5be0353278..55afec6fdad41b7828e56c498843253513da8050 100644 (file)
@@ -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/
index 3237b85ed5cebefe052e8f58e69a481cd9c47e29..482989b86cf347ee6b4e2f111e51260fd2dc872c 100644 (file)
@@ -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);