From d15dfd180662664494d77aa9aa3485f3314e19e1 Mon Sep 17 00:00:00 2001 From: cristy Date: Mon, 13 May 2013 11:21:49 +0000 Subject: [PATCH] --- coders/label.c | 101 +++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/coders/label.c b/coders/label.c index b520282ac..13ec9e045 100644 --- a/coders/label.c +++ b/coders/label.c @@ -137,62 +137,63 @@ static Image *ReadLABELImage(const ImageInfo *image_info, 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 - high, - low; - - /* - Auto fit text into bounding box. - */ - for ( ; ; draw_info->pointsize*=2.0) + else + if (((image->columns == 0) || (image->rows == 0)) || + (fabs(image_info->pointsize) < MagickEpsilon)) { - (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 ((image->columns != 0) && (image->rows != 0)) - { - if ((width > image->columns) && (height > image->rows)) + double + high, + low; + + /* + Auto fit text into bounding box. + */ + for ( ; ; draw_info->pointsize*=2.0) + { + (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 ((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; - for (low=1.0; (high-low) > 1.0; ) - { - draw_info->pointsize=(low+high)/2.0; - (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 ((image->columns != 0) && (image->rows != 0)) - { - if ((width <= image->columns) && (height <= image->rows)) + } + high=draw_info->pointsize; + for (low=1.0; (high-low) > 1.0; ) + { + draw_info->pointsize=(low+high)/2.0; + (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 ((image->columns != 0) && (image->rows != 0)) + { + if ((width <= image->columns) && (height <= image->rows)) + low=draw_info->pointsize+1.0; + else + high=draw_info->pointsize-1.0; + } + else + if (((image->columns != 0) && (width < image->columns)) || + ((image->rows != 0) && (height < image->rows))) low=draw_info->pointsize+1.0; else high=draw_info->pointsize-1.0; - } - else - if (((image->columns != 0) && (width < image->columns)) || - ((image->rows != 0) && (height < image->rows))) - low=draw_info->pointsize+1.0; - else - high=draw_info->pointsize-1.0; + } + draw_info->pointsize=(low+high)/2.0-1.0; } - draw_info->pointsize=(low+high)/2.0-1.0; - } status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); if (status == MagickFalse) { -- 2.40.0