From: Dirk Lemstra Date: Fri, 14 Sep 2018 09:31:09 +0000 (+0200) Subject: Added DrawGetTypeMetrics. X-Git-Tag: 7.0.8-12~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=948b4fcab11747dfa20f630737a668ef07e8de2e;p=imagemagick Added DrawGetTypeMetrics. --- diff --git a/MagickWand/drawing-wand.c b/MagickWand/drawing-wand.c index 8f1e84ff1..d5b6f6c26 100644 --- a/MagickWand/drawing-wand.c +++ b/MagickWand/drawing-wand.c @@ -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); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % D r a w G e t V e c t o r G r a p h i c s % % % % % diff --git a/MagickWand/drawing-wand.h b/MagickWand/drawing-wand.h index 2c453b1ca..263f3951d 100644 --- a/MagickWand/drawing-wand.h +++ b/MagickWand/drawing-wand.h @@ -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),