]> granicus.if.org Git - imagemagick/blobdiff - coders/pango.c
...
[imagemagick] / coders / pango.c
index 0446e44f9846697114916ec5eb99945a0540c9ab..424a525a044fcbf05dc621126cafdd9da7ec4f20 100644 (file)
@@ -6,7 +6,7 @@
 %                     PPPP    AAA   N   N   GGGG   OOO                        %
 %                     P   P  A   A  NN  N  G      O   O                       %
 %                     PPPP   AAAAA  N N N  G GGG  O   O                       %
-%                     P   M  A   A  N  NN  G   G  O   O                       %
+%                     P      A   A  N  NN  G   G  O   O                       %
 %                     P      A   A  N   N   GGGG   OOO                        %
 %                                                                             %
 %                                                                             %
 %                                 March 2012                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2018 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  %
 %  obtain a copy of the License at                                            %
 %                                                                             %
-%    http://www.imagemagick.org/script/license.php                            %
+%    https://www.imagemagick.org/script/license.php                           %
 %                                                                             %
 %  Unless required by applicable law or agreed to in writing, software        %
 %  distributed under the License is distributed on an "AS IS" BASIS,          %
@@ -135,6 +135,9 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
   PangoContext
     *context;
 
+  PangoFontDescription
+    *description;
+
   PangoFontMap
     *fontmap;
 
@@ -169,12 +172,12 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
     Initialize Image structure.
   */
   assert(image_info != (const ImageInfo *) NULL);
-  assert(image_info->signature == MagickSignature);
+  assert(image_info->signature == MagickCoreSignature);
   if (image_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
-  assert(exception->signature == MagickSignature);
+  assert(exception->signature == MagickCoreSignature);
   image=AcquireImage(image_info,exception);
   (void) ResetImagePage(image,"0x0+0+0");
   /*
@@ -281,10 +284,10 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
         pango_layout_set_ellipsize(layout,PANGO_ELLIPSIZE_START);
     }
   option=GetImageOption(image_info,"pango:justify");
-  if (IfMagickTrue(IsStringTrue(option)))
+  if (IsStringTrue(option) != MagickFalse)
     pango_layout_set_justify(layout,1);
   option=GetImageOption(image_info,"pango:single-paragraph");
-  if (IfMagickTrue(IsStringTrue(option)))
+  if (IsStringTrue(option) != MagickFalse)
     pango_layout_set_single_paragraph_mode(layout,1);
   option=GetImageOption(image_info,"pango:wrap");
   if (option != (const char *) NULL)
@@ -321,20 +324,14 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
       (draw_info->direction == RightToLeftDirection))
     align=(PangoAlignment) (PANGO_ALIGN_LEFT+PANGO_ALIGN_RIGHT-align);
   pango_layout_set_alignment(layout,align);
-  if (draw_info->font != (char *) NULL)
-    {
-      PangoFontDescription
-        *description;
-
-      /*
-        Set font.
-      */
-      description=pango_font_description_from_string(draw_info->font);
-      pango_font_description_set_size(description,(int) (PANGO_SCALE*
-        draw_info->pointsize+0.5));
-      pango_layout_set_font_description(layout,description);
-      pango_font_description_free(description);
-    }
+  if (draw_info->font == (char *) NULL)
+    description=pango_font_description_new();
+  else
+    description=pango_font_description_from_string(draw_info->font);
+  pango_font_description_set_size(description,(int) (PANGO_SCALE*
+    draw_info->pointsize+0.5));
+  pango_layout_set_font_description(layout,description);
+  pango_font_description_free(description);
   option=GetImageOption(image_info,"pango:markup");
   if ((option != (const char *) NULL) && (IsStringTrue(option) == MagickFalse))
     pango_layout_set_text(layout,caption,-1);
@@ -401,6 +398,9 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
   cairo_paint(cairo_image);
   cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
   cairo_translate(cairo_image,page.x,page.y);
+  cairo_set_source_rgba(cairo_image,QuantumScale*draw_info->fill.red,
+    QuantumScale*draw_info->fill.green,QuantumScale*draw_info->fill.blue,
+    QuantumScale*draw_info->fill.alpha);
   pango_cairo_show_layout(cairo_image,layout);
   cairo_destroy(cairo_image);
   cairo_surface_destroy(surface);
@@ -435,7 +435,7 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
       /*
         Disassociate alpha.
       */
-      gamma=1.0-QuantumScale*fill_color.alpha;
+      gamma=QuantumScale*fill_color.alpha;
       gamma=PerceptibleReciprocal(gamma);
       fill_color.blue*=gamma;
       fill_color.green*=gamma;
@@ -490,25 +490,24 @@ static Image *ReadPANGOImage(const ImageInfo *image_info,
 ModuleExport size_t RegisterPANGOImage(void)
 {
   char
-    version[MaxTextExtent];
+    version[MagickPathExtent];
 
   MagickInfo
     *entry;
 
   *version='\0';
 #if defined(PANGO_VERSION_STRING)
-  (void) FormatLocaleString(version,MaxTextExtent,"Pangocairo %s",
+  (void) FormatLocaleString(version,MagickPathExtent,"Pangocairo %s",
     PANGO_VERSION_STRING);
 #endif
-  entry=SetMagickInfo("PANGO");
+  entry=AcquireMagickInfo("PANGO","PANGO","Pango Markup Language");
 #if defined(MAGICKCORE_PANGOCAIRO_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadPANGOImage;
 #endif
-  entry->description=ConstantString("Pango Markup Language");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->adjoin=MagickFalse;
-  entry->module=ConstantString("PANGO");
+  entry->flags^=CoderAdjoinFlag;
+  entry->flags^=CoderDecoderThreadSupportFlag;
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }