Main Page | File List | File Members

FTSize.cpp

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     err(0)
00009 {}
00010 
00011 
00012 FTSize::~FTSize()
00013 {}
00014 
00015 
00016 bool FTSize::CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution )
00017 {
00018     err = FT_Set_Char_Size( *face, 0L, point_size * 64, x_resolution, y_resolution);
00019 
00020     if( !err)
00021     {
00022         ftFace = face;
00023         size = point_size;
00024         ftSize = (*ftFace)->size;
00025     }
00026     else
00027     {
00028         ftFace = 0;
00029         size = 0;
00030         ftSize = 0;
00031     }
00032     
00033     return !err;
00034 }
00035 
00036 
00037 unsigned int FTSize::CharSize() const
00038 {
00039     return size;
00040 }
00041 
00042 
00043 float FTSize::Ascender() const
00044 {
00045     return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f;
00046 }
00047 
00048 
00049 float FTSize::Descender() const
00050 {
00051     return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f;
00052 }
00053 
00054 
00055 float FTSize::Height() const
00056 {
00057     if( 0 == ftSize)
00058     {
00059         return 0.0f;
00060     }
00061     
00062     if( FT_IS_SCALABLE((*ftFace)))
00063     {
00064         return ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
00065     }
00066     else
00067     {
00068         return static_cast<float>( ftSize->metrics.height) / 64.0f;
00069     }
00070 }
00071 
00072 
00073 float FTSize::Width() const
00074 {
00075     if( 0 == ftSize)
00076     {
00077         return 0.0f;
00078     }
00079     
00080     if( FT_IS_SCALABLE((*ftFace)))
00081     {
00082         return ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM));
00083     }
00084     else
00085     {
00086         return static_cast<float>( ftSize->metrics.max_advance) / 64.0f;
00087     }
00088 }
00089 
00090 
00091 float FTSize::Underline() const
00092 {
00093     return 0.0f;
00094 }
00095 
00096 unsigned int FTSize::XPixelsPerEm() const
00097 {
00098     return ftSize == 0 ? 0 : ftSize->metrics.x_ppem;
00099 }
00100 
00101 unsigned int FTSize::YPixelsPerEm() const
00102 {
00103     return ftSize == 0 ? 0 : ftSize->metrics.y_ppem;
00104 }
00105 

Generated on Sat Jan 22 09:59:55 2005 for FTGL by doxygen 1.3.6