void FTFont::BBox( const char* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz) { FTBBox totalBBox; if((NULL != string) && ('\0' != *string)) { const unsigned char* c = (unsigned char*)string; CheckGlyph( *c); totalBBox = glyphList->BBox( *c); float advance = glyphList->Advance( *c, *(c + 1)); ++c; while( *c) { CheckGlyph( *c); FTBBox tempBBox = glyphList->BBox( *c); tempBBox.Move( FTPoint( advance, 0.0f, 0.0f)); totalBBox += tempBBox; advance += glyphList->Advance( *c, *(c + 1)); ++c; } } llx = totalBBox.lowerX; lly = totalBBox.lowerY; llz = totalBBox.lowerZ; urx = totalBBox.upperX; ury = totalBBox.upperY; urz = totalBBox.upperZ; }
void FTFont::BBox( const wchar_t* string, float& llx, float& lly, float& llz, float& urx, float& ury, float& urz) { FTBBox totalBBox; if((NULL != string) && ('\0' != *string)) { const wchar_t* c = string; float advance = 0; if(CheckGlyph( *c)) { totalBBox = glyphList->BBox( *c); advance = glyphList->Advance( *c, *(c + 1)); } while( *++c) { if(CheckGlyph( *c)) { FTBBox tempBBox = glyphList->BBox( *c); tempBBox.Move( FTPoint( advance, 0.0f, 0.0f)); totalBBox += tempBBox; advance += glyphList->Advance( *c, *(c + 1)); } } } llx = totalBBox.lowerX; lly = totalBBox.lowerY; llz = totalBBox.lowerZ; urx = totalBBox.upperX; ury = totalBBox.upperY; urz = totalBBox.upperZ; }
inline FTPoint FTFontImpl::RenderI(const T* string, const int len, FTPoint position, FTPoint spacing, int renderMode) { // for multibyte - we can't rely on sizeof(T) == character FTUnicodeStringItr<T> ustr(string); for(int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) { unsigned int thisChar = *ustr++; unsigned int nextChar = *ustr; if(CheckGlyph(thisChar)) { position += glyphList->Render(thisChar, nextChar, position, renderMode); } if(nextChar) { position += spacing; } } return position; }
inline FTPoint FTTextureFont::RenderI(const T* string, const int len, FTPoint position, FTPoint spacing) { if (!FTTextureFont::custom_shader) { Render::set_effect(Render::FONT); } // for multibyte - we can't rely on sizeof(T) == character FTUnicodeStringItr<T> ustr(string); for(int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) { unsigned int thisChar = *ustr++; unsigned int nextChar = *ustr; if (CheckGlyph(thisChar)) { position += glyphList->Render(thisChar, nextChar, position); } if (nextChar) { position += spacing; } } if (!FTTextureFont::custom_shader) { Render::disable_effect(); } return position; }
inline FTBBox FTFontImpl::BBoxI(const T* string, const int len, FTPoint position, FTPoint spacing) { FTBBox totalBBox; /* Only compute the bounds if string is non-empty. */ if(string && ('\0' != string[0])) { // for multibyte - we can't rely on sizeof(T) == character FTUnicodeStringItr<T> ustr(string); unsigned int thisChar = *ustr++; unsigned int nextChar = *ustr; if(CheckGlyph(thisChar)) { totalBBox = glyphList->BBox(thisChar); totalBBox += position; position += FTPoint(glyphList->Advance(thisChar, nextChar), 0.0); } /* Expand totalBox by each glyph in string */ for(int i = 1; (len < 0 && *ustr) || (len >= 0 && i < len); i++) { thisChar = *ustr++; nextChar = *ustr; if(CheckGlyph(thisChar)) { position += spacing; FTBBox tempBBox = glyphList->BBox(thisChar); tempBBox += position; totalBBox |= tempBBox; position += FTPoint(glyphList->Advance(thisChar, nextChar), 0.0); } } } return totalBBox; }
void FTFont::Render (const wchar_t* string) { const wchar_t* c = string; pen.X(0); pen.Y(0); while (*c) { if (CheckGlyph (*c)) pen = glyphList->Render (*c, *(c + 1), pen); ++c; } }
void FTFont::Render (const char* string) { const unsigned char* c = (unsigned char*)string; pen.X(0); pen.Y(0); while (*c) { if (CheckGlyph (*c)) pen = glyphList->Render (*c, *(c + 1), pen); ++c; } }
float FTFont::Advance (const char* string) { const unsigned char* c = (unsigned char*)string; float width = 0.0f; while (*c) { if (CheckGlyph (*c)) width += glyphList->Advance (*c, *(c + 1)); ++c; } return width; }
float FTFont::Advance (const wchar_t* string) { const wchar_t* c = string; float width = 0.0f; while (*c) { if (CheckGlyph (*c)) width += glyphList->Advance (*c, *(c + 1)); ++c; } return width; }
void FTFont::DoRender( const unsigned int chr, const unsigned int nextChr) { CheckGlyph( chr); FTPoint kernAdvance = glyphList->Render( chr, nextChr, pen); // pen.x += kernAdvance.x; if(monospace) { pen.x += kernAdvance.x; } else pen.x += kernAdvance.x; pen.y += kernAdvance.y; }
inline float FTTextureFont::AdvanceI(const T* string, const int len, FTPoint spacing) { float advance = 0.0f; FTUnicodeStringItr<T> ustr(string); for (int i = 0; (len < 0 && *ustr) || (len >= 0 && i < len); i++) { unsigned int thisChar = *ustr++; unsigned int nextChar = *ustr; if (CheckGlyph(thisChar)) { advance += glyphList->Advance(thisChar, nextChar); } if (nextChar) { advance += spacing.Xf(); } } return advance; }