1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
#ifndef __FTBBox__
#define __FTBBox__
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include "FTGL.h"
#include "FTPoint.h"
/**
* FTBBox is a convenience class for handling bounding boxes.
*/
class FTGL_EXPORT FTBBox
{
public:
/**
* Default constructor. Bounding box is set to zero.
*/
FTBBox()
: lowerX(0),
lowerY(0),
lowerZ(0),
upperX(0),
upperY(0),
upperZ(0)
{}
/**
* Constructor. Extracts a bounding box from a freetype glyph. Uses
* the control box for the glyph. <code>FT_Glyph_Get_CBox()</code>
*
* @param glyph A freetype glyph
*/
FTBBox( FT_Glyph glyph)
{
FT_BBox bbox;
FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_subpixels, &bbox );
lowerX = bbox.xMin >> 6;
lowerY = bbox.yMin >> 6;
lowerZ = 0;
upperX = bbox.xMax >> 6;
upperY = bbox.yMax >> 6;
upperZ = 0;
}
/**
* Destructor
*/
~FTBBox()
{}
/**
* Move the Bounding Box by a vector.
*
* @param distance The distance to move the bbox in 3D space.
*/
FTBBox Move( FTPoint distance)
{
lowerX += distance.x;
lowerY += distance.y;
lowerZ += distance.z;
upperX += distance.x;
upperY += distance.y;
upperZ += distance.z;
return *this;
}
/**
* Operator + Adds two FTBBox's together
*
* @param a
* @param b
* @return
*/
friend FTBBox operator + ( const FTBBox &a, const FTBBox &b);
/**
* The bounds of the box
*/
// Make these ftPoints & private
float lowerX, lowerY, lowerZ, upperX, upperY, upperZ;
protected:
private:
};
#endif // __FTBBox__