From: Cristy Date: Sun, 24 Jun 2018 15:34:07 +0000 (-0400) Subject: Correct SVG dx/dy attribute X-Git-Tag: 7.0.8-3~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c63c504e820696ba12af546e38abadde4b8b1a8c;p=imagemagick Correct SVG dx/dy attribute --- diff --git a/ChangeLog b/ChangeLog index a06b71648..269cc092b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2018-06-24 7.0.8-3 Cristy + * Apply translate component of SVG transform rotate. + 2018-06-18 7.0.8-2 Cristy * Release ImageMagick version 7.0.8-2, GIT revision 14476:cda11d81d:20180618. diff --git a/MagickCore/draw.c b/MagickCore/draw.c index afa147005..201a6848d 100644 --- a/MagickCore/draw.c +++ b/MagickCore/draw.c @@ -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; diff --git a/MagickCore/magick-type.h b/MagickCore/magick-type.h index 11f6b8805..0e92f10c3 100644 --- a/MagickCore/magick-type.h +++ b/MagickCore/magick-type.h @@ -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) diff --git a/coders/svg.c b/coders/svg.c index 8fd91e103..3237b85ed 100644 --- a/coders/svg.c +++ b/coders/svg.c @@ -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;