From e275ada1a7f4f90e73328c35e9f02464bafed8be Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 14 Apr 2013 22:29:40 +0000 Subject: [PATCH] --- coders/caption.c | 55 +++++++++++++++++------------------------------- coders/label.c | 10 +++++++-- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/coders/caption.c b/coders/caption.c index b9c837ce0..de8ce0975 100644 --- a/coders/caption.c +++ b/coders/caption.c @@ -157,47 +157,30 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info, MagickFalse,gravity); if (image->columns == 0) { - for ( ; ; draw_info->pointsize*=2.0) - { - text=AcquireString(caption); - i=FormatMagickCaption(image,draw_info,MagickFalse,&metrics,&text, - exception); - (void) CloneString(&draw_info->text,text); - text=DestroyString(text); - (void) FormatLocaleString(geometry,MaxTextExtent,"%+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); - height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); - if ((height >= image->rows) || (image_info->pointsize != 0.0)) - break; - } - draw_info->pointsize/=2.0; + text=AcquireString(caption); + i=FormatMagickCaption(image,draw_info,MagickFalse,&metrics,&text, + exception); + (void) CloneString(&draw_info->text,text); + text=DestroyString(text); + (void) FormatLocaleString(geometry,MaxTextExtent,"%+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); width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5); image->columns=width; } if (image->rows == 0) { - for ( ; ; draw_info->pointsize*=2.0) - { - text=AcquireString(caption); - i=FormatMagickCaption(image,draw_info,MagickFalse,&metrics,&text, - exception); - (void) CloneString(&draw_info->text,text); - text=DestroyString(text); - (void) FormatLocaleString(geometry,MaxTextExtent,"%+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); - 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 ((width >= image->columns) || (image_info->pointsize != 0.0)) - break; - } - draw_info->pointsize/=2.0; + text=AcquireString(caption); + i=FormatMagickCaption(image,draw_info,MagickFalse,&metrics,&text, + exception); + (void) CloneString(&draw_info->text,text); + text=DestroyString(text); + (void) FormatLocaleString(geometry,MaxTextExtent,"%+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); image->rows=(size_t) ((i+1)*(metrics.ascent-metrics.descent+ draw_info->interline_spacing+draw_info->stroke_width)+0.5); @@ -231,7 +214,7 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info, break; } high=draw_info->pointsize; - for (low=high/2.0; (high-low) > 1.0; ) + for (low=1.0; (high-low) > 1.0; ) { draw_info->pointsize=(low+high)/2.0; text=AcquireString(caption); diff --git a/coders/label.c b/coders/label.c index f4025ebfd..cbcbe4331 100644 --- a/coders/label.c +++ b/coders/label.c @@ -131,7 +131,13 @@ static Image *ReadLABELImage(const ImageInfo *image_info, label=GetImageProperty(image,"label",exception); draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); draw_info->text=ConstantString(label); - if (((image->columns == 0) || (image->rows == 0)) && + if ((image->columns == 0) && (image->rows == 0)) + { + status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); + image->columns=(size_t) (metrics.width+draw_info->stroke_width+0.5); + image->rows=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); + } + if (((image->columns == 0) || (image->rows == 0)) || (fabs(image_info->pointsize) < MagickEpsilon)) { double @@ -158,7 +164,7 @@ static Image *ReadLABELImage(const ImageInfo *image_info, break; } high=draw_info->pointsize; - for (low=high/2.0; (high-low) > 1.0; ) + for (low=1.0; (high-low) > 1.0; ) { draw_info->pointsize=(low+high)/2.0; (void) FormatLocaleString(geometry,MaxTextExtent,"%+g%+g", -- 2.40.0