void FTFont::BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz) { const wchar_t* c = string; llx = lly = llz = urx = ury = urz = 0; FTBBox bbox; while( *c) { if( !glyphList->Glyph( static_cast<unsigned int>(*c))) { unsigned int g = face.CharIndex( static_cast<unsigned int>(*c)); glyphList->Add( MakeGlyph( g), g); } bbox = glyphList->BBox( *c); // Lower extent lly = lly < bbox.y1 ? lly: bbox.y1; // Upper extent ury = ury > bbox.y2 ? ury: bbox.y2; // Depth urz = urz < bbox.z2 ? urz: bbox.z2; // Width urx += glyphList->Advance( *c, *(c + 1)); ++c; } //Final adjustments llx = glyphList->BBox( *string).x1; urx -= glyphList->Advance( *(c - 1), 0); urx += bbox.x2; }
void FTFont::CheckGlyph( const unsigned int characterCode) { if( NULL == glyphList->Glyph( characterCode)) { unsigned int glyphIndex = glyphList->FontIndex( characterCode); glyphList->Add( MakeGlyph( glyphIndex), characterCode); } }
float FTFont::doAdvance( const unsigned int chr, const unsigned int nextChr) { if( !glyphList->Glyph( chr)) { unsigned int g = face.CharIndex( chr); glyphList->Add( MakeGlyph( g), g); } return glyphList->Advance( chr, nextChr); }
bool FTFont::CheckGlyph (const unsigned int characterCode) { if (NULL == glyphList->Glyph (characterCode)) { unsigned int glyphIndex = glyphList->FontIndex (characterCode); FTGlyph* tempGlyph = MakeGlyph (glyphIndex); if (NULL == tempGlyph) { if (0 == err) err = 0x13; return false; } glyphList->Add (tempGlyph, characterCode); } return true; }
void FTFont::doRender( const unsigned int chr, const unsigned int nextChr, const FTGLRenderContext *context) { if( !glyphList->Glyph( chr)) { unsigned int g = face.CharIndex( chr); glyphList->Add( MakeGlyph( g), g); } FT_Vector kernAdvance = glyphList->render( chr, nextChr, pen, context); pen.x += kernAdvance.x; pen.y += kernAdvance.y; }
bool FTFont::MakeGlyphList() { if( preCache) { for( unsigned int c = 0; c < numGlyphs; ++c) { glyphList->Add( MakeGlyph( c), c); } } else { for( unsigned int c = 0; c < numGlyphs; ++c) { glyphList->Add( NULL, c); } } return !err; // FIXME what err? }