00001 #ifndef __FTBBox__
00002 #define __FTBBox__
00003
00004 #include <ft2build.h>
00005 #include FT_FREETYPE_H
00006 #include FT_GLYPH_H
00007
00008 #include "FTGL.h"
00009 #include "FTPoint.h"
00010
00011
00015 class FTGL_EXPORT FTBBox
00016 {
00017 public:
00021 FTBBox()
00022 : lowerX(0.0f),
00023 lowerY(0.0f),
00024 lowerZ(0.0f),
00025 upperX(0.0f),
00026 upperY(0.0f),
00027 upperZ(0.0f)
00028 {}
00029
00033 FTBBox( float lx, float ly, float lz, float ux, float uy, float uz)
00034 : lowerX(lx),
00035 lowerY(ly),
00036 lowerZ(lz),
00037 upperX(ux),
00038 upperY(uy),
00039 upperZ(uz)
00040 {}
00041
00048 FTBBox( FT_Glyph glyph)
00049 {
00050 FT_BBox bbox;
00051 FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_subpixels, &bbox );
00052
00053 lowerX = static_cast<float>( bbox.xMin) / 64.0f;
00054 lowerY = static_cast<float>( bbox.yMin) / 64.0f;
00055 lowerZ = 0.0f;
00056 upperX = static_cast<float>( bbox.xMax) / 64.0f;
00057 upperY = static_cast<float>( bbox.yMax) / 64.0f;
00058 upperZ = 0.0f;
00059 }
00060
00064 ~FTBBox()
00065 {}
00066
00067
00073 FTBBox& Move( FTPoint distance)
00074 {
00075 lowerX += distance.x;
00076 lowerY += distance.y;
00077 lowerZ += distance.z;
00078 upperX += distance.x;
00079 upperY += distance.y;
00080 upperZ += distance.z;
00081 return *this;
00082 }
00083
00084 FTBBox& operator += ( const FTBBox& bbox)
00085 {
00086 lowerX = bbox.lowerX < lowerX? bbox.lowerX: lowerX;
00087 lowerY = bbox.lowerY < lowerY? bbox.lowerY: lowerY;
00088 lowerZ = bbox.lowerZ < lowerZ? bbox.lowerZ: lowerZ;
00089 upperX = bbox.upperX > upperX? bbox.upperX: upperX;
00090 upperY = bbox.upperY > upperY? bbox.upperY: upperY;
00091 upperZ = bbox.upperZ > upperZ? bbox.upperZ: upperZ;
00092
00093 return *this;
00094 }
00095
00099
00100 float lowerX, lowerY, lowerZ, upperX, upperY, upperZ;
00101 protected:
00102
00103
00104 private:
00105
00106 };
00107
00108
00109 #endif // __FTBBox__
00110