]> granicus.if.org Git - imagemagick/blobdiff - coders/ttf.c
...
[imagemagick] / coders / ttf.c
index 4a1f6eae8a73ead83b0a92e86deb6bf10fd7960c..cc346d441b2cd3b8dc5a855b6f69593e3cc82448 100644 (file)
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  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,          %
@@ -167,7 +167,7 @@ static MagickBooleanType IsTTF(const unsigned char *magick,const size_t length)
 static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   char
-    buffer[MaxTextExtent],
+    buffer[MagickPathExtent],
     *text;
 
   const char
@@ -205,19 +205,19 @@ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Open image file.
   */
   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);
   image->columns=800;
   image->rows=480;
   type_info=GetTypeInfo(image_info->filename,exception);
   if ((type_info != (const TypeInfo *) NULL) &&
       (type_info->glyphs != (char *) NULL))
-    (void) CopyMagickString(image->filename,type_info->glyphs,MaxTextExtent);
+    (void) CopyMagickString(image->filename,type_info->glyphs,MagickPathExtent);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     {
@@ -244,8 +244,9 @@ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (SyncAuthenticPixels(image,exception) == MagickFalse)
       break;
   }
-  (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent);
-  (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
+  (void) CopyMagickString(image->magick,image_info->magick,MagickPathExtent);
+  (void) CopyMagickString(image->filename,image_info->filename,
+    MagickPathExtent);
   /*
     Prepare drawing commands
   */
@@ -253,29 +254,30 @@ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
   draw_info->font=AcquireString(image->filename);
   ConcatenateString(&draw_info->primitive,"push graphic-context\n");
-  (void) FormatLocaleString(buffer,MaxTextExtent," viewbox 0 0 %.20g %.20g\n",
-    (double) image->columns,(double) image->rows);
+  (void) FormatLocaleString(buffer,MagickPathExtent,
+    " viewbox 0 0 %.20g %.20g\n",(double) image->columns,(double) image->rows);
   ConcatenateString(&draw_info->primitive,buffer);
   ConcatenateString(&draw_info->primitive," font-size 18\n");
-  (void) FormatLocaleString(buffer,MaxTextExtent," text 10,%.20g '",(double) y);
+  (void) FormatLocaleString(buffer,MagickPathExtent," text 10,%.20g '",
+    (double) y);
   ConcatenateString(&draw_info->primitive,buffer);
   text=EscapeString(Text,'"');
   ConcatenateString(&draw_info->primitive,text);
   text=DestroyString(text);
-  (void) FormatLocaleString(buffer,MaxTextExtent,"'\n");
+  (void) FormatLocaleString(buffer,MagickPathExtent,"'\n");
   ConcatenateString(&draw_info->primitive,buffer);
   y+=20*(ssize_t) MultilineCensus((char *) Text)+20;
   for (i=12; i <= 72; i+=6)
   {
     y+=i+12;
     ConcatenateString(&draw_info->primitive," font-size 18\n");
-    (void) FormatLocaleString(buffer,MaxTextExtent," text 10,%.20g '%.20g'\n",
-      (double) y,(double) i);
+    (void) FormatLocaleString(buffer,MagickPathExtent,
+      " text 10,%.20g '%.20g'\n",(double) y,(double) i);
     ConcatenateString(&draw_info->primitive,buffer);
-    (void) FormatLocaleString(buffer,MaxTextExtent," font-size %.20g\n",
+    (void) FormatLocaleString(buffer,MagickPathExtent," font-size %.20g\n",
       (double) i);
     ConcatenateString(&draw_info->primitive,buffer);
-    (void) FormatLocaleString(buffer,MaxTextExtent," text 50,%.20g "
+    (void) FormatLocaleString(buffer,MagickPathExtent," text 50,%.20g "
       "'That which does not destroy me, only makes me stronger.'\n",(double) y);
     ConcatenateString(&draw_info->primitive,buffer);
     if (i >= 24)
@@ -318,81 +320,69 @@ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 ModuleExport size_t RegisterTTFImage(void)
 {
   char
-    version[MaxTextExtent];
+    version[MagickPathExtent];
 
   MagickInfo
     *entry;
 
   *version='\0';
 #if defined(FREETYPE_MAJOR) && defined(FREETYPE_MINOR) && defined(FREETYPE_PATCH)
-  (void) FormatLocaleString(version,MaxTextExtent,"Freetype %d.%d.%d",
+  (void) FormatLocaleString(version,MagickPathExtent,"Freetype %d.%d.%d",
     FREETYPE_MAJOR,FREETYPE_MINOR,FREETYPE_PATCH);
 #endif
-  entry=SetMagickInfo("DFONT");
+  entry=AcquireMagickInfo("TTF","DFONT","Multi-face font package");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsTTF;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("Multi-face font package");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("PFA");
+  entry=AcquireMagickInfo("TTF","PFA","Postscript Type 1 font (ASCII)");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsPFA;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("Postscript Type 1 font (ASCII)");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("PFB");
+  entry=AcquireMagickInfo("TTF","PFB","Postscript Type 1 font (binary)");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsPFA;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("Postscript Type 1 font (binary)");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("OTF");
+  entry=AcquireMagickInfo("TTF","OTF","Open Type font");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsTTF;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("Open Type font");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("TTC");
+  entry=AcquireMagickInfo("TTF","TTC","TrueType font collection");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsTTF;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("TrueType font collection");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
-  entry=SetMagickInfo("TTF");
+  entry=AcquireMagickInfo("TTF","TTF","TrueType font");
 #if defined(MAGICKCORE_FREETYPE_DELEGATE)
   entry->decoder=(DecodeImageHandler *) ReadTTFImage;
 #endif
   entry->magick=(IsImageFormatHandler *) IsTTF;
   entry->flags^=CoderAdjoinFlag;
-  entry->description=ConstantString("TrueType font");
   if (*version != '\0')
     entry->version=ConstantString(version);
-  entry->module=ConstantString("TTF");
   (void) RegisterMagickInfo(entry);
   return(MagickImageCoderSignature);
 }