예제 #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;
 }
예제 #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;
}
예제 #3
0
파일: Font.cpp 프로젝트: JSandrew4/FastGdk
	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();
	}
예제 #4
0
 double length ( const std::string & str ) { 
     return m_font->Advance ( str.c_str() ); 
 }