]> granicus.if.org Git - imagemagick/commitdiff
Correct SVG dx/dy attribute
authorCristy <urban-warrior@imagemagick.org>
Sun, 24 Jun 2018 15:34:07 +0000 (11:34 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sun, 24 Jun 2018 15:34:07 +0000 (11:34 -0400)
ChangeLog
MagickCore/draw.c
MagickCore/magick-type.h
coders/svg.c

index a06b71648fddb4d1d1d1c2e762268f8a370127c7..269cc092ba49090436a8b04a4bef4ddbce28c034 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2018-06-24  7.0.8-3 Cristy  <quetzlzacatenango@image...>
+  * Apply translate component of SVG transform rotate.
+
 2018-06-18  7.0.8-2 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-2, GIT revision 14476:cda11d81d:20180618.
 
index afa147005fb34af7ac7eaea4fd080e849e23de14..201a6848dffc96ce790dc80d5b79dc847cd71d65 100644 (file)
@@ -3632,7 +3632,7 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
         if (LocaleCompare("text",keyword) == 0)
           {
             primitive_type=TextPrimitive;
-            affine.tx+=cursor;
+            /* affine.tx+=cursor; */
             break;
           }
         if (LocaleCompare("text-align",keyword) == 0)
@@ -3800,9 +3800,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
            if (number_stops > 0)
              stops=(StopInfo *) RelinquishMagickMemory(stops);
           }
-        if (image->debug != MagickFalse)
+        if ((image->debug != MagickFalse) && (q > p))
           (void) LogMagickEvent(DrawEvent,GetMagickModule(),"  %.*s",(int)
-            (q-p),p);
+            (q-p-1),p);
         continue;
       }
     /*
@@ -4210,8 +4210,9 @@ MagickExport MagickBooleanType DrawImage(Image *image,const DrawInfo *draw_info,
     mvg_info.offset=i;
     if (primitive_info == (PrimitiveInfo *) NULL)
       break;
-    if (image->debug != MagickFalse)
-      (void) LogMagickEvent(DrawEvent,GetMagickModule(),"  %.*s",(int) (q-p),p);
+    if ((image->debug != MagickFalse) && (q > p))
+      (void) LogMagickEvent(DrawEvent,GetMagickModule(),"  %.*s",(int) (q-p-1),
+        p);
     if (status == MagickFalse)
       break;
     primitive_info[i].primitive=UndefinedPrimitive;
index 11f6b8805126e0df829a11c74be1f2a4d8f06d65..0e92f10c35694efbd10e196a28ce8d67d011fb25 100644 (file)
@@ -107,7 +107,7 @@ typedef MagickDoubleType Quantum;
 #else
 #error "MAGICKCORE_QUANTUM_DEPTH must be one of 8, 16, 32, or 64"
 #endif
-#define MagickEpsilon  (1.0e-15)
+#define MagickEpsilon  (1.0e-12)
 #define MagickMaximumValue  1.79769313486231570E+308
 #define MagickMinimumValue   2.22507385850720140E-308
 #define QuantumScale  ((double) 1.0/(double) QuantumRange)
index 8fd91e103ee27a05d0643520517503d8ea4b04e2..3237b85ed5cebefe052e8f58e69a481cd9c47e29 100644 (file)
@@ -1594,13 +1594,24 @@ static void SVGStartElement(void *context,const xmlChar *name,
             }
           if (LocaleCompare(keyword,"dx") == 0)
             {
-              svg_info->bounds.x+=GetUserSpaceCoordinateValue(svg_info,1,value);
+              double
+                dx;
+
+              dx=GetUserSpaceCoordinateValue(svg_info,1,value);
+              svg_info->bounds.x+=dx;
+              if (LocaleCompare((char *) name,"text") == 0)
+                (void) FormatLocaleFile(svg_info->file,"translate %g,0.0\n",dx);
               break;
             }
           if (LocaleCompare(keyword,"dy") == 0)
             {
-              svg_info->bounds.y+=
-                GetUserSpaceCoordinateValue(svg_info,-1,value);
+              double
+                dy;
+
+              dy=GetUserSpaceCoordinateValue(svg_info,-1,value);
+              svg_info->bounds.y+=dy;
+              if (LocaleCompare((char *) name,"text") == 0)
+                (void) FormatLocaleFile(svg_info->file,"translate 0.0,%g\n",dy);
               break;
             }
           break;
@@ -2132,22 +2143,20 @@ static void SVGStartElement(void *context,const xmlChar *name,
                         p=(const char *) value;
                         GetNextToken(p,&p,MagickPathExtent,token);
                         angle=StringToDouble(value,(char **) NULL);
+                        affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
+                        affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
+                        affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
+                        affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
                         GetNextToken(p,&p,MagickPathExtent,token);
                         if (*token == ',')
                           GetNextToken(p,&p,MagickPathExtent,token);
-                        x=StringToDouble(token,&next_token);
+                        x=StringToDouble(token,&next_token)-svg_info->bounds.x;
                         GetNextToken(p,&p,MagickPathExtent,token);
                         if (*token == ',')
                           GetNextToken(p,&p,MagickPathExtent,token);
-                        y=StringToDouble(token,&next_token);
-                        affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
-                        affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
-                        affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
-                        affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
-                        affine.tx=0.0;
-                        affine.ty=0.0;
-                        svg_info->center.x=x;
-                        svg_info->center.y=y;
+                        y=StringToDouble(token,&next_token)-svg_info->bounds.y;
+                        affine.tx=svg_info->bounds.x+x*cos(angle)-y*sin(angle);
+                        affine.ty=svg_info->bounds.y+x*sin(angle)+y*cos(angle);
                         break;
                       }
                     break;