]> granicus.if.org Git - imagemagick/commitdiff
Use switch() rather than a complex if/else
authorCristy <urban-warrior@imagemagick.org>
Sat, 29 Jun 2019 13:16:54 +0000 (09:16 -0400)
committerCristy <urban-warrior@imagemagick.org>
Sat, 29 Jun 2019 13:16:54 +0000 (09:16 -0400)
MagickCore/annotate.c

index e72cb94a30c3125829e38a288c5b3a54d0d63523..5e110306a79920b7a01b75176e7fd0992385cedf 100644 (file)
@@ -498,41 +498,43 @@ MagickExport MagickBooleanType AnnotateImage(Image *image,
       }
     annotate_info->affine.tx=offset.x;
     annotate_info->affine.ty=offset.y;
-
     pixel=annotate_info->fill;
     if (annotate_info->stroke.alpha != TransparentAlpha)
-      pixel = annotate_info->stroke;
-
+      pixel=annotate_info->stroke;
     (void) QueryColorname(image,&pixel,AllCompliance,color,exception);
     (void) FormatLocaleString(primitive,MagickPathExtent,"stroke %s "
-      "stroke-width %g "
-      "line 0,0 %g,0",color,(double) metrics.underline_thickness,(double) metrics.width);
-
+      "stroke-width %g line 0,0 %g,0",color,(double)
+      metrics.underline_thickness,(double) metrics.width);
     /*
       Annotate image with text.
     */
-    if (annotate->decorate == OverlineDecoration)
+    switch (annotate->decorate)
+    {
+      case OverlineDecoration:
       {
         annotate_info->affine.ty-=(draw_info->affine.sy*(metrics.ascent+
           metrics.descent-metrics.underline_position));
         (void) CloneString(&annotate_info->primitive,primitive);
         (void) DrawImage(image,annotate_info,exception);
+        break;
       }
-    else if (annotate->decorate == UnderlineDecoration)
+      case UnderlineDecoration:
+      default:
       {
         annotate_info->affine.ty-=(draw_info->affine.sy*
           metrics.underline_position);
         (void) CloneString(&annotate_info->primitive,primitive);
         (void) DrawImage(image,annotate_info,exception);
+        break;
       }
-    else if (annotate->decorate == LineThroughDecoration)
+      case LineThroughDecoration:
       {
         annotate_info->affine.ty-=(draw_info->affine.sy*(height+
           metrics.underline_position+metrics.descent*2)/2.0);
         (void) CloneString(&annotate_info->primitive,primitive);
         (void) DrawImage(image,annotate_info,exception);
       }
-
+    }
     status=RenderType(image,annotate,&offset,&metrics,exception);
     if (status == MagickFalse)
       break;
@@ -1476,9 +1478,10 @@ static MagickBooleanType RenderFreetype(Image *image,const DrawInfo *draw_info,
   metrics->bounds.y1=metrics->descent;
   metrics->bounds.x2=metrics->ascent+metrics->descent;
   metrics->bounds.y2=metrics->ascent+metrics->descent;
-  metrics->underline_position=face->underline_position*(metrics->pixels_per_em.x/face->units_per_EM);
-  metrics->underline_thickness=face->underline_thickness*(metrics->pixels_per_em.x/face->units_per_EM);
-
+  metrics->underline_position=face->underline_position*
+    (metrics->pixels_per_em.x/face->units_per_EM);
+  metrics->underline_thickness=face->underline_thickness*
+    (metrics->pixels_per_em.x/face->units_per_EM);
   if ((draw_info->text == (char *) NULL) || (*draw_info->text == '\0'))
     {
       (void) FT_Done_Face(face);