本文整理汇总了C++中sf::Font::getGlyph方法的典型用法代码示例。如果您正苦于以下问题:C++ Font::getGlyph方法的具体用法?C++ Font::getGlyph怎么用?C++ Font::getGlyph使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Font
的用法示例。
在下文中一共展示了Font::getGlyph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: id
sf::Vector2f Renderer::LoadFont( const sf::Font& font, unsigned int size, sf::Color background_color_hint, sf::Color foreground_color_hint ) {
// Get the font face that Laurent tries to hide from us.
struct FontStruct {
void* font_face; // Authentic SFML comment: implementation details
void* unused1;
int* unused2;
// Since maps allocate everything non-contiguously on the heap we can use void* instead of Page here.
mutable std::map<unsigned int, void*> unused3;
mutable std::vector<sf::Uint8> unused4;
};
void* face;
// All your font face are belong to us too.
memcpy( &face, reinterpret_cast<const char*>( &font ) + sizeof( sf::Font ) - sizeof( FontStruct ), sizeof( void* ) );
FontID id( face, size );
std::map<FontID, sf::Vector2f>::iterator iter( m_font_offsets.find( id ) );
if( iter != m_font_offsets.end() ) {
return iter->second;
}
// Make sure all the glyphs we need are loaded.
for( sf::Uint32 codepoint = 0; codepoint < 512; ++codepoint ) {
font.getGlyph( codepoint, size, false );
}
sf::Image image = font.getTexture( size ).copyToImage();
sf::Vector2f offset = LoadImage( image, background_color_hint, foreground_color_hint, true );
m_font_offsets[id] = offset;
return offset;
}