Main Page | File List | File Members

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(); 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; 00078 float advance = 0; 00079 00080 unsigned int left = charMap->FontIndex( characterCode); 00081 unsigned int right = charMap->FontIndex( nextCharacterCode); 00082 00083 kernAdvance = face->KernAdvance( left, right); 00084 00085 if( !face->Error()) 00086 { 00087 advance = glyphs[charMap->GlyphListIndex( characterCode)]->Render( penPosition); 00088 } 00089 00090 kernAdvance.x = advance + kernAdvance.x; 00091 // kernAdvance.y = advance.y + kernAdvance.y; 00092 return kernAdvance; 00093 }

Generated on Sun Nov 21 06:30:04 2004 for FTGL by doxygen 1.3.7