Beispiel #1
0
 double kerning ( char a, char b ) { 
     //silly hack.
     //kerning = advance ( ab ) - ( advance ( a ) + advance ( b ) )
     static char st[7];
     double r; 
     // st = 'ab0a0b0'
     st[2] = st[4] = st[6] = 0;
     st[0] = st[3] = a;
     st[1] = st[5] = b;
     r  = m_font->Advance ( st );
     r -= m_font->Advance ( st+3 );
     r -= m_font->Advance ( st+5 );
     return r;
 }
Beispiel #2
0
bool OglRenderer::getStringBBox(char *font, double size, char *string, rectObj *rect, double** advances)
{
  FTFont* face = getFTFont(font, size);
  if (!face) {
    msSetError(MS_OGLERR, "Failed to load font (%s).", "OglRenderer::getStringBBox()", font);
    return false;
  }

  float llx =0.0f, lly=0.0f, llz=0.0f, urx=0.0f, ury=0.0f, urz=0.0f;
  glPushAttrib( GL_ALL_ATTRIB_BITS );
  FTBBox boundingBox = face->BBox(string);
  glPopAttrib();

  rect->minx = boundingBox.Lower().X();
  rect->maxx = boundingBox.Upper().X();
  rect->miny = -boundingBox.Upper().Y();
  rect->maxy = -boundingBox.Lower().Y();

  if (advances) {
    int length = strlen(string);
    *advances = new double[length];
    for (int i = 0; i < length; ++i) {
      (*advances)[i] = face->Advance(&string[i], 1);
    }
  }

  return true;
}
Beispiel #3
0
	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();
	}
Beispiel #4
0
 double length ( const std::string & str ) { 
     return m_font->Advance ( str.c_str() ); 
 }