From: Dirk Lemstra Date: Fri, 4 May 2018 22:49:46 +0000 (+0200) Subject: Added extra properties to TypeMetric (#1121) X-Git-Tag: 7.0.7-31~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d30b2791eb6f589a38667eab36fa336778aae43;p=imagemagick Added extra properties to TypeMetric (#1121) --- diff --git a/Magick++/lib/Magick++/TypeMetric.h b/Magick++/lib/Magick++/TypeMetric.h index 338616b9d..cf779d389 100644 --- a/Magick++/lib/Magick++/TypeMetric.h +++ b/Magick++/lib/Magick++/TypeMetric.h @@ -1,7 +1,7 @@ // This may look like C code, but it is really -*- C++ -*- // // Copyright Bob Friesenhahn, 2001, 2002 -// Copyright Dirk Lemstra 2014 +// Copyright Dirk Lemstra 2014-2018 // // TypeMetric Definition // @@ -12,6 +12,7 @@ #define Magick_TypeMetric_header #include "Magick++/Include.h" +#include "Magick++/Drawable.h" namespace Magick { @@ -27,18 +28,26 @@ namespace Magick // Destructor ~TypeMetric(void); - // Ascent, the distance in pixels from the text baseline to the - // highest/upper grid coordinate used to place an outline point. + // The distance in pixels from the text baseline to the highest/upper + // grid coordinate used to place an outline point. double ascent(void) const; - // Descent, the distance in pixels from the baseline to the lowest - // grid coordinate used to place an outline point. Always a - // negative value. + // The bounds of the type metric. + Geometry bounds(void) const; + + // The distance in pixels from the baseline to the lowest grid coordinate + // used to place an outline point. Always a negative value. double descent(void) const; // Maximum horizontal advance in pixels. double maxHorizontalAdvance(void) const; + // The origin. + Coordinate origin(void) const; + + // The number of pixels per em. + Coordinate pixelsPerEm(void) const; + // Text height in pixels. double textHeight(void) const; diff --git a/Magick++/lib/TypeMetric.cpp b/Magick++/lib/TypeMetric.cpp index 2d8e29b65..b6e725b5f 100644 --- a/Magick++/lib/TypeMetric.cpp +++ b/Magick++/lib/TypeMetric.cpp @@ -1,7 +1,7 @@ // This may look like C code, but it is really -*- C++ -*- // // Copyright Bob Friesenhahn, 2001 -// Copyright Dirk Lemstra 2014 +// Copyright Dirk Lemstra 2014-2018 // // TypeMetric implementation // @@ -10,6 +10,7 @@ #define MAGICK_PLUSPLUS_IMPLEMENTATION 1 #include "Magick++/TypeMetric.h" +#include "Magick++/Drawable.h" #include Magick::TypeMetric::TypeMetric(void) @@ -26,6 +27,13 @@ double Magick::TypeMetric::ascent(void) const return(_typeMetric.ascent); } +Magick::Geometry Magick::TypeMetric::bounds(void) const +{ + return(Geometry((size_t) _typeMetric.bounds.x2-_typeMetric.bounds.x1, + (size_t) _typeMetric.bounds.y2-_typeMetric.bounds.y1,(ssize_t) + _typeMetric.bounds.x1,(ssize_t) _typeMetric.bounds.y1)); +} + double Magick::TypeMetric::descent(void) const { return(_typeMetric.descent); @@ -36,6 +44,16 @@ double Magick::TypeMetric::maxHorizontalAdvance(void) const return(_typeMetric.max_advance); } +Magick::Coordinate Magick::TypeMetric::origin(void) const +{ + return(Coordinate(_typeMetric.origin.x,_typeMetric.origin.y)); +} + +Magick::Coordinate Magick::TypeMetric::pixelsPerEm(void) const +{ + return(Coordinate(_typeMetric.pixels_per_em.x,_typeMetric.pixels_per_em.y)); +} + double Magick::TypeMetric::textHeight(void) const { return(_typeMetric.height);