]> granicus.if.org Git - imagemagick/commitdiff
Added DrawGetTypeMetrics.
authorDirk Lemstra <dirk@git.imagemagick.org>
Fri, 14 Sep 2018 09:31:09 +0000 (11:31 +0200)
committerDirk Lemstra <dirk@git.imagemagick.org>
Fri, 14 Sep 2018 09:31:09 +0000 (11:31 +0200)
MagickWand/drawing-wand.c
MagickWand/drawing-wand.h

index 8f1e84ff138b73fb9568a9c7bd8e93295e2a55ee..d5b6f6c26cf119039769897c4f5a0a03f5c003af 100644 (file)
@@ -2434,6 +2434,81 @@ WandExport double DrawGetTextInterwordSpacing(DrawingWand *wand)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   D r a w G e t T y p e M e t r i c s                                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DrawGetTypeMetrics() returns the following information for the specified
+%  font and text:
+%
+%    character width
+%    character height
+%    ascender
+%    descender
+%    text width
+%    text height
+%    maximum horizontal advance
+%    bounds: x1
+%    bounds: y1
+%    bounds: x2
+%    bounds: y2
+%    origin: x
+%    origin: y
+%    underline position
+%    underline thickness
+%
+%  The format of the DrawGetTypeMetrics method is:
+%
+%      MagickBooleanType DrawGetTypeMetrics(const DrawingWand *wand,
+%        const char *text,MagickBooleanType ignore_newlines,
+$        TypeMetric *metrics)
+%
+%  A description of each parameter follows:
+%
+%    o wand: the drawing wand.
+%
+%    o text: text to draw.
+%
+%    o metrics: Return the font metrics in this structure.
+%
+%    o ignore_newlines: indicates whether newlines should be ignored.
+%
+%    o metrics: Return the font metrics in this structure.
+%
+*/
+WandExport MagickBooleanType DrawGetTypeMetrics(const DrawingWand *wand,
+  const char *text,MagickBooleanType ignore_newlines,TypeMetric *metrics)
+{
+  DrawInfo
+    *draw_info;
+
+  MagickBooleanType
+    status;
+
+  assert(wand != (const DrawingWand *) NULL);
+  assert(wand->signature == MagickWandSignature);
+  if (wand->debug != MagickFalse)
+    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
+  draw_info=PeekDrawingWand(wand);
+  if (draw_info == (DrawInfo *) NULL)
+    return(MagickFalse);
+  (void) CloneString(&draw_info->text,text);
+  if (ignore_newlines != MagickFalse)
+    status=GetTypeMetrics(wand->image,draw_info,metrics,wand->exception);
+  else
+    status=GetMultilineTypeMetrics(wand->image,draw_info,metrics,
+      wand->exception);
+  draw_info=DestroyDrawInfo(draw_info);
+  return(status);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   D r a w G e t V e c t o r G r a p h i c s                                 %
 %                                                                             %
 %                                                                             %
index 2c453b1ca9127c8349c0cdb9bd30e3ab07a2e0bd..263f3951d0ef561b5adb512c42616b6d0acd6d37 100644 (file)
@@ -90,11 +90,13 @@ extern WandExport LineJoin
 
 extern WandExport MagickBooleanType
   DrawClearException(DrawingWand *),
-  DrawComposite(DrawingWand *,const CompositeOperator,const double,const double,
-    const double,const double,MagickWand *),
+  DrawComposite(DrawingWand *,const CompositeOperator,const double,
+    const double,const double,const double,MagickWand *),
   DrawGetFontResolution(const DrawingWand *,double *,double *),
   DrawGetStrokeAntialias(const DrawingWand *),
   DrawGetTextAntialias(const DrawingWand *),
+  DrawGetTypeMetrics(const DrawingWand *,const char *,MagickBooleanType,
+    TypeMetric *),
   DrawPopPattern(DrawingWand *),
   DrawPushPattern(DrawingWand *,const char *,const double,const double,
     const double,const double),