]> granicus.if.org Git - imagemagick/commitdiff
Added option to limit the maximum point size.
authorDirk Lemstra <dirk@lemstra.org>
Fri, 23 Aug 2019 07:43:54 +0000 (09:43 +0200)
committerDirk Lemstra <dirk@lemstra.org>
Fri, 23 Aug 2019 07:43:54 +0000 (09:43 +0200)
ChangeLog
coders/caption.c

index cfc99c6da79677227b6bd3b108c8c91833f9aa03..3b6e5c733677536cefd3f212fc702a8ffd52777f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 2019-08-19  7.0.8-62 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-62, GIT revision 16...
 
+2019-08-23  7.0.8-62 Dirk Lemstra <dirk@lem.....org>
+  * Added option to limit the maximum point size with -define
+    caption:max-pointsize=pointsize.
+
 2019-08-19  7.0.8-62 Cristy  <quetzlzacatenango@image...>
   * Conditionally compile call to AcquireCLocale() (reference
     https://github.com/ImageMagick/ImageMagick/issues/1669).
index 20e757545aa4f09e58127b1e0167dc15647e1eec..929b24933e1ec7ebe0033aef742649b8d1866576 100644 (file)
@@ -225,33 +225,44 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info,
       /*
         Auto fit text into bounding box.
       */
-      for (n=0; n < 32; n++, draw_info->pointsize*=2.0)
-      {
-        text=AcquireString(caption);
-        i=FormatMagickCaption(image,draw_info,split,&metrics,&text,
-          exception);
-        (void) CloneString(&draw_info->text,text);
-        text=DestroyString(text);
-        (void) FormatLocaleString(geometry,MagickPathExtent,"%+g%+g",
-          -metrics.bounds.x1,metrics.ascent);
-        if (draw_info->gravity == UndefinedGravity)
-          (void) CloneString(&draw_info->geometry,geometry);
-        status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
-        if (status == MagickFalse)
-          break;
-        width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
-        height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
-        if ((image->columns != 0) && (image->rows != 0))
+      option=GetImageOption(image_info,"caption:max-pointsize");
+      if (option != (const char*) NULL)
+        {
+          high=StringToDouble(option,(char**) NULL);
+          if (high < 1.0)
+            high=1.0;
+          high+=1.0;
+        }
+      else
+        {
+          for (n=0; n < 32; n++, draw_info->pointsize*=2.0)
           {
-            if ((width >= image->columns) && (height >= image->rows))
+            text=AcquireString(caption);
+            i=FormatMagickCaption(image,draw_info,split,&metrics,&text,
+              exception);
+            (void) CloneString(&draw_info->text,text);
+            text=DestroyString(text);
+            (void) FormatLocaleString(geometry,MagickPathExtent,"%+g%+g",
+              -metrics.bounds.x1,metrics.ascent);
+            if (draw_info->gravity == UndefinedGravity)
+              (void) CloneString(&draw_info->geometry,geometry);
+            status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
+            if (status == MagickFalse)
               break;
+            width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
+            height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
+            if ((image->columns != 0) && (image->rows != 0))
+              {
+                if ((width >= image->columns) && (height >= image->rows))
+                  break;
+              }
+            else
+              if (((image->columns != 0) && (width >= image->columns)) ||
+                  ((image->rows != 0) && (height >= image->rows)))
+                break;
           }
-        else
-          if (((image->columns != 0) && (width >= image->columns)) ||
-              ((image->rows != 0) && (height >= image->rows)))
-            break;
-      }
-      high=draw_info->pointsize;
+          high=draw_info->pointsize;
+        }
       for (low=1.0; (high-low) > 0.5; )
       {
         draw_info->pointsize=(low+high)/2.0;