void Font::GetStringSize(const String &text, Vector2D *result) { if (mID < 0) { *result = kFastVector2DZero; return; } FTFont *tf = (FTFont*)GetCollection()->GetResource(mID)->GetFTFont(); result->mX = tf->Advance(text.GetWString().mData); result->mY = tf->LineHeight(); }
void Writter::Draw(string iname, string str, float x, float y, float mangle){ FTFont* nfont = m_font_list[iname]; if (nfont != NULL){ glPushMatrix(); glTranslatef(x, -y - nfont->LineHeight(), 0); glRotatef(mangle, 0.0, 0.0, 1); nfont->Render(str.c_str()); glPopMatrix(); }else{ fprintf(stderr, "Failed to draw using name '%s': %s\n", iname.c_str(), str.c_str()); } }
AudicleFTGLFont( char * name ) { glEnable ( GL_TEXTURE_2D ); char fontlocation[512]; strncpy ( fontlocation, fontpath, 512 ); strncat ( fontlocation, name, 512 - strlen ( fontlocation ) ); m_font = new FTGLTextureFont ( fontlocation ); if ( m_font->Error() ) { fprintf(stderr, "AudicleFTGLFont: font load error %d - exiting\n", m_font->Error() ); exit(1); } else { if ( !m_font->FaceSize(18) ) { fprintf(stderr, "AudicleFTGLFont: font size error %d - exiting\n", m_font->Error() ); exit(1); } m_name = name; m_font->Depth(2); m_font->CharMap(ft_encoding_unicode); glDisable ( GL_TEXTURE_2D ); float x1, y1, z1, x2, y2, z2; m_font->BBox( samplestring , x1, y1, z1, x2, y2, z2); m_height = y2; m_line_height = m_font->LineHeight(); m_height_unit_scale = 1.0 / m_height ; m_line_unit_scale = 1.0 / m_line_height ; m_mono_width = m_height; } }