Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FTGlyphContainer.cpp

Go to the documentation of this file.
00001 #include    "FTGlyphContainer.h"
00002 #include    "FTGlyph.h"
00003 #include    "FTFace.h"
00004 #include    "FTCharmap.h"
00005 
00006 
00007 FTGlyphContainer::FTGlyphContainer( FTFace* f)
00008 :   face(f),
00009     err(0)
00010 {
00011     glyphs.push_back( NULL);
00012     charMap = new FTCharmap( face);
00013 }
00014 
00015 
00016 FTGlyphContainer::~FTGlyphContainer()
00017 {
00018     GlyphVector::iterator glyphIterator;
00019     for( glyphIterator = glyphs.begin(); glyphIterator != glyphs.end(); ++glyphIterator)
00020     {
00021         delete *glyphIterator;
00022     }
00023     
00024     glyphs.clear();
00025     delete charMap;
00026 }
00027 
00028 
00029 bool FTGlyphContainer::CharMap( FT_Encoding encoding)
00030 {
00031     bool result = charMap->CharMap( encoding);
00032     err = charMap->Error();
00033     return result;
00034 }
00035 
00036 
00037 unsigned int FTGlyphContainer::FontIndex( const unsigned int characterCode) const
00038 {
00039     return charMap->FontIndex( characterCode);
00040 }
00041 
00042 
00043 void FTGlyphContainer::Add( FTGlyph* tempGlyph, const unsigned int characterCode)
00044 {
00045     charMap->InsertIndex( characterCode, glyphs.size());
00046     glyphs.push_back( tempGlyph);
00047 }
00048 
00049 
00050 const FTGlyph* const FTGlyphContainer::Glyph( const unsigned int characterCode) const
00051 {
00052     signed int index = charMap->GlyphListIndex( characterCode);
00053     return glyphs[index];
00054 }
00055 
00056 
00057 FTBBox FTGlyphContainer::BBox( const unsigned int characterCode) const
00058 {
00059     return glyphs[charMap->GlyphListIndex( characterCode)]->BBox();
00060 }
00061 
00062 
00063 float FTGlyphContainer::Advance( const unsigned int characterCode, const unsigned int nextCharacterCode)
00064 {
00065     unsigned int left = charMap->FontIndex( characterCode);
00066     unsigned int right = charMap->FontIndex( nextCharacterCode);
00067 
00068     float width = face->KernAdvance( left, right).X();
00069     width += glyphs[charMap->GlyphListIndex( characterCode)]->Advance().X();
00070     
00071     return width;
00072 }
00073 
00074 
00075 FTPoint FTGlyphContainer::Render( const unsigned int characterCode, const unsigned int nextCharacterCode, FTPoint penPosition)
00076 {
00077     FTPoint kernAdvance, advance;
00078     
00079     unsigned int left = charMap->FontIndex( characterCode);
00080     unsigned int right = charMap->FontIndex( nextCharacterCode);
00081 
00082     kernAdvance = face->KernAdvance( left, right);
00083         
00084     if( !face->Error())
00085     {
00086         advance = glyphs[charMap->GlyphListIndex( characterCode)]->Render( penPosition);
00087     }
00088     
00089     kernAdvance += advance;
00090     return kernAdvance;
00091 }

Generated on Sun Dec 5 22:24:06 2004 for FTGL by doxygen 1.3.6