예제 #1
0
FTGlyph* FTGLTextureFont::MakeGlyph (unsigned int glyphIndex) {
	FT_GlyphSlot ftGlyph = face.Glyph (glyphIndex, FT_LOAD_NO_HINTING);
	
	if (ftGlyph) {
		glyphHeight = static_cast<int> (charSize.Height());
		glyphWidth = static_cast<int> (charSize.Width());

		if (textureIDList.empty()) {
			textureIDList.push_back (CreateTexture());
			xOffset = yOffset = padding;
		}

		if (xOffset >  (textureWidth - glyphWidth)) {
			xOffset = padding;
			yOffset += glyphHeight;
			if (yOffset >  (textureHeight - glyphHeight)) {
				textureIDList.push_back (CreateTexture());
				yOffset = padding;
			}
		}

		FTTextureGlyph* tempGlyph =
				new FTTextureGlyph (ftGlyph, textureIDList[textureIDList.size() - 1],
				xOffset, yOffset, textureWidth, textureHeight);
		xOffset += static_cast<int> (tempGlyph->BBox().upperX - tempGlyph->BBox().lowerX + padding);

		--remGlyphs;
		return tempGlyph;
	}
	err = face.Error();
	return NULL;
}
예제 #2
0
FTGlyph* FTTextureFontImpl::MakeGlyphImpl(FT_GlyphSlot ftGlyph)
{
    glyphHeight = static_cast<int>(charSize.Height() + 0.5);
    glyphWidth = static_cast<int>(charSize.Width() + 0.5);

    if(glyphHeight < 1) glyphHeight = 1;
    if(glyphWidth < 1) glyphWidth = 1;

    if(textureIDList.empty())
    {
        textureIDList.push_back(CreateTexture());
        xOffset = yOffset = padding;
    }

    if(xOffset > (textureWidth - glyphWidth))
    {
        xOffset = padding;
        yOffset += glyphHeight;

        if(yOffset > (textureHeight - glyphHeight))
        {
            textureIDList.push_back(CreateTexture());
            yOffset = padding;
        }
    }

    FTTextureGlyph* tempGlyph = new FTTextureGlyph(ftGlyph, textureIDList[textureIDList.size() - 1],
                                                    xOffset, yOffset, textureWidth, textureHeight);
    xOffset += static_cast<int>(tempGlyph->BBox().Upper().X() - tempGlyph->BBox().Lower().X() + padding + 0.5);

    --remGlyphs;

    return tempGlyph;
}
FTGlyph* FTGLTextureFont::MakeGlyph( unsigned int g)
{
  FT_Glyph* ftGlyph = face.Glyph( g, FT_LOAD_NO_HINTING);
  
  if( ftGlyph)
  {
    // Estimate the glyph size size - global bbox
    glyphHeight = ( charSize.Height());
    glyphWidth = ( charSize.Width());
    
    // Is there a current texture
    if( numTextures == 0)
    {
      glTextureID[0] = CreateTexture();
      xOffset = yOffset = padding;
      ++numTextures;
    }
    
    // will it fit in the current texture
    if( xOffset > ( textureWidth - glyphWidth))
    {
      xOffset = padding;
      yOffset += glyphHeight;
      
      if( yOffset > ( textureHeight - glyphHeight))
      {
        // no - make a new texture
        glTextureID[numTextures] = CreateTexture();
        yOffset = padding;
        ++numTextures;
      }
    }
    
    // yes - load the glyph
    FTTextureGlyph* tempGlyph = new FTTextureGlyph( *ftGlyph, glTextureID[numTextures - 1],
                              xOffset, yOffset, textureWidth, textureHeight);
    
    // FIXME ceiling
                xOffset += (int)(tempGlyph->BBox().x2 - tempGlyph->BBox().x1 + padding);
    
    --remGlyphs;
    return tempGlyph;
  }
  
  err = face.Error();
  return NULL;

}