FTSize.cxx

Go to the documentation of this file.
00001 #include    "FTSize.h"
00002 
00003 
00004 FTSize::FTSize()
00005 :   ftFace(0),
00006     ftSize(0),
00007     size(0),
00008     xResolution(0),
00009     yResolution(0),
00010     err(0)
00011 {}
00012 
00013 
00014 FTSize::~FTSize()
00015 {}
00016 
00017 
00018 bool FTSize::CharSize( FT_Face* face, unsigned int pointSize, unsigned int xRes, unsigned int yRes )
00019 {
00020     if (size != pointSize || xResolution != xRes || yResolution != yRes) {
00021         err = FT_Set_Char_Size( *face, 0L, pointSize * 64, xResolution, yResolution);
00022 
00023         if (!err) {
00024             ftFace = face;
00025             size = pointSize;
00026             xResolution = xRes;
00027             yResolution = yRes;
00028             ftSize = (*ftFace)->size;
00029         } else {
00030             ftFace = 0;
00031             size = 0;
00032             xResolution = 0;
00033             yResolution = 0;
00034             ftSize = 0;
00035         }
00036     }
00037     
00038     return !err;
00039 }
00040 
00041 
00042 unsigned int FTSize::CharSize() const
00043 {
00044     return size;
00045 }
00046 
00047 
00048 float FTSize::Ascender() const
00049 {
00050     return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f;
00051 }
00052 
00053 
00054 float FTSize::Descender() const
00055 {
00056     return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f;
00057 }
00058 
00059 
00060 float FTSize::Height() const
00061 {
00062     if (0 == ftSize) return 0.0f;
00063     
00064     if (FT_IS_SCALABLE((*ftFace))) {
00065         return ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
00066     } else {
00067         return static_cast<float>( ftSize->metrics.height) / 64.0f;
00068     }
00069 }
00070 
00071 
00072 float FTSize::Width() const
00073 {
00074     if( 0 == ftSize) return 0.0f;
00075     
00076     if( FT_IS_SCALABLE((*ftFace))) {
00077         return ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM));
00078     } else {
00079         return static_cast<float>( ftSize->metrics.max_advance) / 64.0f;
00080     }
00081 }
00082 
00083 
00084 float FTSize::Underline() const
00085 {
00086     return 0.0f;
00087 }

Generated on Tue Jul 5 14:16:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1