]> granicus.if.org Git - imagemagick/blobdiff - coders/pango.c
Allow older versions of SVG library
[imagemagick] / coders / pango.c
index 3262b353f843257c72e3153807560ac64d67c84a..e4e1cb237c7241ef7d52dc8fb389d198ef65cbd2 100644 (file)
@@ -17,7 +17,7 @@
 %                                 March 2012                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -193,7 +193,7 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
   */
   fontmap=pango_cairo_font_map_new();
   pango_cairo_font_map_set_resolution(PANGO_CAIRO_FONT_MAP(fontmap),
-    image->resolution.x);
+    image->resolution.x == 0.0 ? 90.0 : image->resolution.x);
   font_options=cairo_font_options_create();
   option=GetImageOption(image_info,"pango:hinting");
   if (option != (const char *) NULL)
@@ -293,7 +293,8 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
   option=GetImageOption(image_info,"pango:indent");
   if (option != (const char *) NULL)
     pango_layout_set_indent(layout,(int) ((StringToLong(option)*
-      image->resolution.x*PANGO_SCALE+36)/72.0+0.5));
+      (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)*PANGO_SCALE+36)/
+      90.0+0.5));
   switch (draw_info->align)
   {
     case CenterAlign: align=PANGO_ALIGN_CENTER; break;
@@ -349,25 +350,27 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
     (void) ParseAbsoluteGeometry(image_info->page,&page);
   if (image->columns == 0)
     {
-      pango_layout_get_pixel_extents(layout,NULL,&extent);
-      image->columns=extent.x+extent.width+2*page.x;
+      pango_layout_get_extents(layout,NULL,&extent);
+      image->columns=(extent.x+extent.width+PANGO_SCALE/2)/PANGO_SCALE+2*page.x;
     }
   else
     {
       image->columns-=2*page.x;
       pango_layout_set_width(layout,(int) ((PANGO_SCALE*image->columns*
-        image->resolution.x+36.0)/72.0+0.5));
+        (image->resolution.x == 0.0 ? 90.0 : image->resolution.x)+45.0)/90.0+
+        0.5));
     }
   if (image->rows == 0)
     {
-      pango_layout_get_pixel_extents(layout,NULL,&extent);
-      image->rows=extent.y+extent.height+2*page.y;
+      pango_layout_get_extents(layout,NULL,&extent);
+      image->rows=(extent.y+extent.height+PANGO_SCALE/2)/PANGO_SCALE+2*page.y;
     }
   else
     {
       image->rows-=2*page.y;
       pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
-        image->resolution.y+36.0)/72.0+0.5));
+        (image->resolution.y == 0.0 ? 90.0 : image->resolution.y)+45.0)/90.0+
+        0.5));
     }
   /*
     Render markup.
@@ -416,19 +419,19 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
       double
         gamma;
 
-      fill_color.blue=(MagickRealType) ScaleCharToQuantum(*p++);
-      fill_color.green=(MagickRealType) ScaleCharToQuantum(*p++);
-      fill_color.red=(MagickRealType) ScaleCharToQuantum(*p++);
-      fill_color.alpha=(MagickRealType) ScaleCharToQuantum(*p++);
+      fill_color.blue=(double) ScaleCharToQuantum(*p++);
+      fill_color.green=(double) ScaleCharToQuantum(*p++);
+      fill_color.red=(double) ScaleCharToQuantum(*p++);
+      fill_color.alpha=(double) ScaleCharToQuantum(*p++);
       /*
         Disassociate alpha.
       */
       gamma=1.0-QuantumScale*fill_color.alpha;
-      gamma=ClampReciprocal(gamma);
+      gamma=PerceptibleReciprocal(gamma);
       fill_color.blue*=gamma;
       fill_color.green*=gamma;
       fill_color.red*=gamma;
-      CompositePixelOver(image,&fill_color,fill_color.alpha,q,(MagickRealType)
+      CompositePixelOver(image,&fill_color,fill_color.alpha,q,(double)
         GetPixelAlpha(image,q),q);
       q+=GetPixelChannels(image);
     }