]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 27 Mar 2010 23:44:00 +0000 (23:44 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 27 Mar 2010 23:44:00 +0000 (23:44 +0000)
ChangeLog
magick/annotate.c
magick/distort.c
magick/token-private.h
magick/xml-tree.c

index b755033e7a6d029098850f6aeded6db0831cb7d4..e4f0d522528c06e3d5dccc56b836add404d42382 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2010-03-21  6.6.0-10 Cristy  <quetzlzacatenango@image...>
   * Respect the -density option when rendering a Postscript or PDF image.
+  * Distort barrel no longer complains when 3 arguments are given (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=15883).
 
 2010-03-24  6.6.0-9 Glenn Randers-Pehrson <glennrp@image...>
   * coders/png.c: Eliminated support of libpng versions older than 1.0.12.
index 21d23026298ac1d8f9bc2fbe04aac7d21251f22a..d077a86142ae1d20d7a690f87ec6b287658c87a2 100644 (file)
@@ -880,6 +880,7 @@ static MagickBooleanType RenderType(Image *image,const DrawInfo *draw_info,
 */
 
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
+
 static int TraceCubicBezier(FT_Vector *p,FT_Vector *q,FT_Vector *to,
   DrawInfo *draw_info)
 {
@@ -1025,6 +1026,9 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
       0, 0
     };
 
+  unsigned char
+    *utf8;
+
   /*
     Initialize Truetype library.
   */
@@ -1180,368 +1184,198 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
     }
   point.x=0.0;
   point.y=0.0;
-  code=0;
   for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
     if (GetUTFCode(p) < 0)
       break;
+  utf8=(unsigned char *) NULL;
   if (GetUTFCode(p) == 0)
-    for (p=draw_info->text; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
+    p=draw_info->text;
+  else
     {
-      /*
-        Render UTF-8 sequence.
-      */
-      glyph.id=FT_Get_Char_Index(face,GetUTFCode(p));
-      if (glyph.id == 0)
-        glyph.id=FT_Get_Char_Index(face,'?');
-      if ((glyph.id != 0) && (last_glyph.id != 0))
-        {
-          if (draw_info->kerning != 0.0)
-            origin.x+=64.0*draw_info->kerning;
-          else
-            if (FT_HAS_KERNING(face))
-              {
-                FT_Vector
-                  kerning;
+      utf8=ConvertLatin1ToUTF8((unsigned char *) draw_info->text);
+      if (utf8 != (unsigned char *) NULL)
+        p=utf8;
+    }
+  for (code=0; GetUTFCode(p) != 0; p+=GetUTFOctets(p))
+  {
+    /*
+      Render UTF-8 sequence.
+    */
+    glyph.id=FT_Get_Char_Index(face,GetUTFCode(p));
+    if (glyph.id == 0)
+      glyph.id=FT_Get_Char_Index(face,'?');
+    if ((glyph.id != 0) && (last_glyph.id != 0))
+      {
+        if (draw_info->kerning != 0.0)
+          origin.x+=64.0*draw_info->kerning;
+        else
+          if (FT_HAS_KERNING(face))
+            {
+              FT_Vector
+                kerning;
 
-                status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
-                  ft_kerning_default,&kerning);
-                if (status == 0)
-                  origin.x+=kerning.x;
-              }
-          }
-      glyph.origin=origin;
-      status=FT_Load_Glyph(face,glyph.id,flags);
-      if (status != 0)
-        continue;
-      status=FT_Get_Glyph(face->glyph,&glyph.image);
-      if (status != 0)
-        continue;
-      status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
-        &bounds);
-      if (status != 0)
-        continue;
-      if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
-        metrics->bounds.x1=bounds.xMin;
-      if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
-        metrics->bounds.y1=bounds.yMin;
-      if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
-        metrics->bounds.x2=bounds.xMax;
-      if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
-        metrics->bounds.y2=bounds.yMax;
-      if (draw_info->render != MagickFalse)
-        if ((draw_info->stroke.opacity != TransparentOpacity) ||
-            (draw_info->stroke_pattern != (Image *) NULL))
-          {
-            /*
-              Trace the glyph.
-            */
-            annotate_info->affine.tx=glyph.origin.x/64.0;
-            annotate_info->affine.ty=glyph.origin.y/64.0;
-            (void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
-              outline,&OutlineMethods,annotate_info);
-          }
-      FT_Vector_Transform(&glyph.origin,&affine);
-      (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
-      status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
-        (FT_Vector *) NULL,MagickTrue);
-      if (status != 0)
-        continue;
-      bitmap=(FT_BitmapGlyph) glyph.image;
-      point.x=offset->x+bitmap->left;
-      point.y=offset->y-bitmap->top;
-      if (draw_info->render != MagickFalse)
+              status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
+                ft_kerning_default,&kerning);
+              if (status == 0)
+                origin.x+=kerning.x;
+            }
+        }
+    glyph.origin=origin;
+    status=FT_Load_Glyph(face,glyph.id,flags);
+    if (status != 0)
+      continue;
+    status=FT_Get_Glyph(face->glyph,&glyph.image);
+    if (status != 0)
+      continue;
+    status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
+      &bounds);
+    if (status != 0)
+      continue;
+    if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
+      metrics->bounds.x1=bounds.xMin;
+    if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
+      metrics->bounds.y1=bounds.yMin;
+    if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
+      metrics->bounds.x2=bounds.xMax;
+    if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
+      metrics->bounds.y2=bounds.yMax;
+    if (draw_info->render != MagickFalse)
+      if ((draw_info->stroke.opacity != TransparentOpacity) ||
+          (draw_info->stroke_pattern != (Image *) NULL))
         {
-          CacheView
-            *image_view;
-
-          ExceptionInfo
-            *exception;
-
-          MagickBooleanType
-            status;
-
           /*
-            Rasterize the glyph.
+            Trace the glyph.
           */
-          status=MagickTrue;
-          exception=(&image->exception);
-          image_view=AcquireCacheView(image);
-          for (y=0; y < (long) bitmap->bitmap.rows; y++)
-          {
-            long
-              x_offset,
-              y_offset;
-
-            MagickBooleanType
-              active,
-              sync;
-
-            MagickRealType
-              fill_opacity;
-
-            PixelPacket
-              fill_color;
-
-            register long
-              x;
-
-            register PixelPacket
-              *restrict q;
-
-            register unsigned char
-              *p;
-
-            if (status == MagickFalse)
-              continue;
-            x_offset=(long) ceil(point.x-0.5);
-            y_offset=(long) ceil(point.y+y-0.5);
-            if ((y_offset < 0) || (y_offset >= (long) image->rows))
-              continue;
-            q=(PixelPacket *) NULL;
-            if ((x_offset < 0) || (x_offset >= (long) image->columns))
-              active=MagickFalse;
-            else
-              {
-                q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
-                  bitmap->bitmap.width,1,exception);
-                active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
-              }
-            p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
-            for (x=0; x < (long) bitmap->bitmap.width; x++)
-            {
-              x_offset++;
-              if ((*p == 0) || (x_offset < 0) ||
-                  (x_offset >= (long) image->columns))
-                {
-                  p++;
-                  q++;
-                  continue;
-                }
-              fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
-              if (draw_info->text_antialias == MagickFalse)
-                fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
-              if (active == MagickFalse)
-                q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
-                  exception);
-              if (q == (PixelPacket *) NULL)
-                {
-                  p++;
-                  q++;
-                  continue;
-                }
-              (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
-              fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
-                fill_color.opacity);
-              MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
-              if (active == MagickFalse)
-                {
-                  sync=SyncCacheViewAuthenticPixels(image_view,exception);
-                  if (sync == MagickFalse)
-                    status=MagickFalse;
-                }
-              p++;
-              q++;
-            }
-            sync=SyncCacheViewAuthenticPixels(image_view,exception);
-            if (sync == MagickFalse)
-              status=MagickFalse;
-          }
-          image_view=DestroyCacheView(image_view);
+          annotate_info->affine.tx=glyph.origin.x/64.0;
+          annotate_info->affine.ty=glyph.origin.y/64.0;
+          (void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
+            outline,&OutlineMethods,annotate_info);
         }
-      if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
-        metrics->width=bitmap->left+bitmap->bitmap.width;
-      if ((draw_info->interword_spacing != 0.0) &&
-          (IsUTFSpace(GetUTFCode(p)) != MagickFalse) &&
-          (IsUTFSpace(code) == MagickFalse))
-        origin.x+=64.0*draw_info->interword_spacing;
-      else
-        origin.x+=face->glyph->advance.x;
-      metrics->origin.x=origin.x;
-      metrics->origin.y=origin.y;
-      if (last_glyph.id != 0)
-        FT_Done_Glyph(last_glyph.image);
-      last_glyph=glyph;
-      code=GetUTFCode(p);
-    }
-  else
-    for (p=draw_info->text; *p != 0; p++)
-    {
-      /*
-        Render Latin-1 sequence.
-      */
-      glyph.id=FT_Get_Char_Index(face,(unsigned char) *p);
-      if (glyph.id == 0)
-        glyph.id=FT_Get_Char_Index(face,'?');
-      if ((glyph.id != 0) && (last_glyph.id != 0))
-        {
-          if (draw_info->kerning != 0.0)
-            origin.x+=64.0*draw_info->kerning;
-          else
-            if (FT_HAS_KERNING(face))
-              {
-                FT_Vector
-                  kerning;
+    FT_Vector_Transform(&glyph.origin,&affine);
+    (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
+    status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
+      (FT_Vector *) NULL,MagickTrue);
+    if (status != 0)
+      continue;
+    bitmap=(FT_BitmapGlyph) glyph.image;
+    point.x=offset->x+bitmap->left;
+    point.y=offset->y-bitmap->top;
+    if (draw_info->render != MagickFalse)
+      {
+        CacheView
+          *image_view;
 
-                status=FT_Get_Kerning(face,last_glyph.id,glyph.id,
-                  ft_kerning_default,&kerning);
-                if (status == 0)
-                  origin.x+=kerning.x;
-              }
-          }
-      glyph.origin=origin;
-      status=FT_Load_Glyph(face,glyph.id,flags);
-      if (status != 0)
-        continue;
-      status=FT_Get_Glyph(face->glyph,&glyph.image);
-      if (status != 0)
-        continue;
-      status=FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph.image)->outline,
-        &bounds);
-      if (status != 0)
-        continue;
-      if ((p == draw_info->text) || (bounds.xMin < metrics->bounds.x1))
-        metrics->bounds.x1=bounds.xMin;
-      if ((p == draw_info->text) || (bounds.yMin < metrics->bounds.y1))
-        metrics->bounds.y1=bounds.yMin;
-      if ((p == draw_info->text) || (bounds.xMax > metrics->bounds.x2))
-        metrics->bounds.x2=bounds.xMax;
-      if ((p == draw_info->text) || (bounds.yMax > metrics->bounds.y2))
-        metrics->bounds.y2=bounds.yMax;
-      if (draw_info->render != MagickFalse)
-        if ((draw_info->stroke.opacity != TransparentOpacity) ||
-            (draw_info->stroke_pattern != (Image *) NULL))
-          {
-            /*
-              Trace the glyph.
-            */
-            annotate_info->affine.tx=glyph.origin.x/64.0;
-            annotate_info->affine.ty=glyph.origin.y/64.0;
-            (void) FT_Outline_Decompose(&((FT_OutlineGlyph) glyph.image)->
-              outline,&OutlineMethods,annotate_info);
-          }
-      FT_Vector_Transform(&glyph.origin,&affine);
-      (void) FT_Glyph_Transform(glyph.image,&affine,&glyph.origin);
-      status=FT_Glyph_To_Bitmap(&glyph.image,ft_render_mode_normal,
-        (FT_Vector *) NULL,MagickTrue);
-      if (status != 0)
-        continue;
-      bitmap=(FT_BitmapGlyph) glyph.image;
-      point.x=offset->x+bitmap->left;
-      point.y=offset->y-bitmap->top;
-      if (draw_info->render != MagickFalse)
-        {
-          CacheView
-            *image_view;
+        ExceptionInfo
+          *exception;
 
-          ExceptionInfo
-            *exception;
+        MagickBooleanType
+          status;
+
+        /*
+          Rasterize the glyph.
+        */
+        status=MagickTrue;
+        exception=(&image->exception);
+        image_view=AcquireCacheView(image);
+        for (y=0; y < (long) bitmap->bitmap.rows; y++)
+        {
+          long
+            x_offset,
+            y_offset;
 
           MagickBooleanType
-            status;
+            active,
+            sync;
 
-          /*
-            Rasterize the glyph.
-          */
-          status=MagickTrue;
-          exception=(&image->exception);
-          image_view=AcquireCacheView(image);
-          for (y=0; y < (long) bitmap->bitmap.rows; y++)
+          MagickRealType
+            fill_opacity;
+
+          PixelPacket
+            fill_color;
+
+          register long
+            x;
+
+          register PixelPacket
+            *restrict q;
+
+          register unsigned char
+            *p;
+
+          if (status == MagickFalse)
+            continue;
+          x_offset=(long) ceil(point.x-0.5);
+          y_offset=(long) ceil(point.y+y-0.5);
+          if ((y_offset < 0) || (y_offset >= (long) image->rows))
+            continue;
+          q=(PixelPacket *) NULL;
+          if ((x_offset < 0) || (x_offset >= (long) image->columns))
+            active=MagickFalse;
+          else
+            {
+              q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
+                bitmap->bitmap.width,1,exception);
+              active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
+            }
+          p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
+          for (x=0; x < (long) bitmap->bitmap.width; x++)
           {
-            long
-              x_offset,
-              y_offset;
-
-            MagickBooleanType
-              active,
-              sync;
-
-            MagickRealType
-              fill_opacity;
-
-            PixelPacket
-              fill_color;
-
-            register long
-              x;
-
-            register PixelPacket
-              *restrict q;
-
-            register unsigned char
-              *p;
-
-            if (status == MagickFalse)
-              continue;
-            x_offset=(long) ceil(point.x-0.5);
-            y_offset=(long) ceil(point.y+y-0.5);
-            if ((y_offset < 0) || (y_offset >= (long) image->rows))
-              continue;
-            q=(PixelPacket *) NULL;
-            if ((x_offset < 0) || (x_offset >= (long) image->columns))
-              active=MagickFalse;
-            else
+            x_offset++;
+            if ((*p == 0) || (x_offset < 0) ||
+                (x_offset >= (long) image->columns))
               {
-                q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,
-                  bitmap->bitmap.width,1,exception);
-                active=q != (PixelPacket *) NULL ? MagickTrue : MagickFalse;
+                p++;
+                q++;
+                continue;
               }
-            p=bitmap->bitmap.buffer+y*bitmap->bitmap.width;
-            for (x=0; x < (long) bitmap->bitmap.width; x++)
-            {
-              x_offset++;
-              if ((*p == 0) || (x_offset < 0) ||
-                  (x_offset >= (long) image->columns))
-                {
-                  p++;
-                  q++;
-                  continue;
-                }
-              fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
-              if (draw_info->text_antialias == MagickFalse)
-                fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
-              if (active == MagickFalse)
-                q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
-                  exception);
-              if (q == (PixelPacket *) NULL)
-                {
-                  p++;
-                  q++;
-                  continue;
-                }
-              (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
-              fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
-                fill_color.opacity);
-              MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
-              if (active == MagickFalse)
-                {
-                  sync=SyncCacheViewAuthenticPixels(image_view,exception);
-                  if (sync == MagickFalse)
-                    status=MagickFalse;
-                }
-              p++;
-              q++;
-            }
-            sync=SyncCacheViewAuthenticPixels(image_view,exception);
-            if (sync == MagickFalse)
-              status=MagickFalse;
+            fill_opacity=(MagickRealType) (*p)/(bitmap->bitmap.num_grays-1);
+            if (draw_info->text_antialias == MagickFalse)
+              fill_opacity=fill_opacity >= 0.5 ? 1.0 : 0.0;
+            if (active == MagickFalse)
+              q=GetCacheViewAuthenticPixels(image_view,x_offset,y_offset,1,1,
+                exception);
+            if (q == (PixelPacket *) NULL)
+              {
+                p++;
+                q++;
+                continue;
+              }
+            (void) GetFillColor(draw_info,x_offset,y_offset,&fill_color);
+            fill_opacity=QuantumRange-fill_opacity*(QuantumRange-
+              fill_color.opacity);
+            MagickCompositeOver(&fill_color,fill_opacity,q,q->opacity,q);
+            if (active == MagickFalse)
+              {
+                sync=SyncCacheViewAuthenticPixels(image_view,exception);
+                if (sync == MagickFalse)
+                  status=MagickFalse;
+              }
+            p++;
+            q++;
           }
-          image_view=DestroyCacheView(image_view);
+          sync=SyncCacheViewAuthenticPixels(image_view,exception);
+          if (sync == MagickFalse)
+            status=MagickFalse;
         }
-      if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
-        metrics->width=bitmap->left+bitmap->bitmap.width;
-      if ((draw_info->interword_spacing != 0.0) &&
-          (isspace((int) ((unsigned char) *p)) != 0) &&
-          (isspace((int) code) == 0))
-        origin.x+=64.0*draw_info->interword_spacing;
-      else
-        origin.x+=face->glyph->advance.x;
-      metrics->origin.x=origin.x;
-      metrics->origin.y=origin.y;
-      if (last_glyph.id != 0)
-        FT_Done_Glyph(last_glyph.image);
-      last_glyph=glyph;
-      code=(*p);
-    }
+        image_view=DestroyCacheView(image_view);
+      }
+    if ((bitmap->left+bitmap->bitmap.width) > metrics->width)
+      metrics->width=bitmap->left+bitmap->bitmap.width;
+    if ((draw_info->interword_spacing != 0.0) &&
+        (IsUTFSpace(GetUTFCode(p)) != MagickFalse) &&
+        (IsUTFSpace(code) == MagickFalse))
+      origin.x+=64.0*draw_info->interword_spacing;
+    else
+      origin.x+=face->glyph->advance.x;
+    metrics->origin.x=origin.x;
+    metrics->origin.y=origin.y;
+    if (last_glyph.id != 0)
+      FT_Done_Glyph(last_glyph.image);
+    last_glyph=glyph;
+    code=GetUTFCode(p);
+  }
+  if (utf8 != (unsigned char *) NULL)
+    utf8=(unsigned char *) RelinquishMagickMemory(utf8);
   if (last_glyph.id != 0)
     FT_Done_Glyph(last_glyph.image);
   if ((draw_info->stroke.opacity != TransparentOpacity) ||
index f353cee3b205d330135725cc2cab73bfcc71ba0f..0d44e0f30fdf1b8997ea6d3b10a517d118802480 100644 (file)
@@ -352,7 +352,7 @@ static double *GenerateCoefficients(const Image *image,
   /* If not enough control point pairs are found for specific distortions
     fall back to Affine distortion (allowing 0 to 3 point pairs)
   */
-  if ( number_arguments < 4*cp_size && 
+  if ( number_arguments < 4*cp_size &&
        (  *method == BilinearForwardDistortion
        || *method == BilinearReverseDistortion
        || *method == PerspectiveDistortion
@@ -1234,22 +1234,25 @@ static double *GenerateCoefficients(const Image *image,
       double
         rscale = 2.0/MagickMin((double) image->columns,(double) image->rows);
 
-      if ( number_arguments != 4 && number_arguments != 6 &&
-           number_arguments != 8 && number_arguments != 10 ) {
-        coeff=(double *) RelinquishMagickMemory(coeff);
-        (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
-               "InvalidArgument", "%s : '%s'", "Barrel(Inv)",
-               "number of arguments" );
-        return((double *) NULL);
-      }
       /* A,B,C,D coefficients */
       coeff[0] = arguments[0];
       coeff[1] = arguments[1];
       coeff[2] = arguments[2];
-      if ( number_arguments == 3 || number_arguments == 5 )
+      if ((number_arguments == 3) || (number_arguments == 5))
         coeff[3] = 1 - arguments[0] - arguments[1] - arguments[2];
       else
-         coeff[3] = arguments[3];
+        {
+          if ((number_arguments != 4) && (number_arguments != 6) &&
+              (number_arguments != 8) && (number_arguments != 10))
+            {
+              coeff=(double *) RelinquishMagickMemory(coeff);
+              (void) ThrowMagickException(exception,GetMagickModule(),
+                OptionError,"InvalidArgument", "%s : '%s'", "Barrel(Inv)",
+                "number of arguments" );
+              return((double *) NULL);
+            }
+          coeff[3] = arguments[3];
+        }
       /* de-normalize the X coefficients */
       coeff[0] *= pow(rscale,3.0);
       coeff[1] *= rscale*rscale;
index bd8b5fe0b5af1e342f7cf91d4d11a80ba0e620cf..a2d6be7e1ddb84b293519e7bca51642519024c3f 100644 (file)
@@ -48,6 +48,47 @@ static UTFInfo
     { 0xFE, 0xFC, 0x7ffffff, 0x4000000 },  /* 6 byte sequence */
   };
 
+static inline unsigned char *ConvertLatin1ToUTF8(const unsigned char *content)
+{
+  register const unsigned char
+    *p;
+
+  register unsigned char
+    *q;
+
+  size_t
+    length;
+
+  unsigned char
+    *utf8;
+
+  unsigned int
+    c;
+
+  length=0;
+  for (p=content; *p != '\0'; p++)
+    length+=(*p & 0x80) != 0 ? 2 : 1;
+  utf8=(unsigned char *) NULL;
+  if (~length >= 1)
+    utf8=(unsigned char *) AcquireQuantumMemory(length+1UL,sizeof(*utf8));
+  if (utf8 == (unsigned char *) NULL)
+    return((unsigned char *) NULL);
+  q=utf8;
+  for (p=content; *p != '\0'; p++)
+  {
+    c=(*p);
+    if ((c & 0x80) == 0)
+      *q++=c;
+    else
+      {
+        *q++=0xc0 | ((c >> 6) & 0x3f);
+        *q++=0x80 | (c & 0x3f);
+      }
+  }
+  *q='\0';
+  return(utf8);
+}
+
 static inline long GetNextUTFCode(const char *text,size_t *octets)
 {
   long
index 5851322cb8209b75dbe1a1154a09a09db4d200e4..f197d39aacd4a54df450dfa0065027236ac63bfc 100644 (file)
@@ -56,6 +56,7 @@
 #include "magick/semaphore.h"
 #include "magick/string_.h"
 #include "magick/string-private.h"
+#include "magick/token-private.h"
 #include "magick/xml-tree.h"
 #include "magick/utility.h"
 \f
@@ -290,48 +291,6 @@ MagickExport XMLTreeInfo *AddPathToXMLTree(XMLTreeInfo *xml_info,
 %      entities.
 %
 */
-
-static unsigned char *ConvertLatin1ToUTF8(const unsigned char *content)
-{
-  register const unsigned char
-    *p;
-
-  register unsigned char
-    *q;
-
-  size_t
-    length;
-
-  unsigned char
-    *utf8;
-
-  unsigned int
-    c;
-
-  length=0;
-  for (p=content; *p != '\0'; p++)
-    length+=(*p & 0x80) != 0 ? 2 : 1;
-  utf8=(unsigned char *) NULL;
-  if (~length >= 1)
-    utf8=(unsigned char *) AcquireQuantumMemory(length+1UL,sizeof(*utf8));
-  if (utf8 == (unsigned char *) NULL)
-    return((unsigned char *) NULL);
-  q=utf8;
-  for (p=content; *p != '\0'; p++)
-  {
-    c=(*p);
-    if ((c & 0x80) == 0)
-      *q++=c;
-    else
-      {
-        *q++=0xc0 | ((c >> 6) & 0x3f);
-        *q++=0x80 | (c & 0x3f);
-      }
-  }
-  *q='\0';
-  return(utf8);
-}
-
 MagickExport char *CanonicalXMLContent(const char *content,
   const MagickBooleanType pedantic)
 {