Public Member Functions | |
virtual void | load () |
virtual void | rasterize (utf32 start_codepoint, utf32 end_codepoint) |
Protected Types | |
typedef std::vector< Imageset * > | ImagesetVector |
Protected Member Functions | |
void | drawGlyphToBuffer (argb_t *buffer, uint buf_width) |
Copy the current glyph data into buffer, which has a width of buf_width pixels (not bytes). | |
uint | getTextureSize (CodepointMap::const_iterator s, CodepointMap::const_iterator e) |
Return the required texture size required to store imagery for the glyphs from s to e. | |
FreeTypeFont (const String &name, const String &filename, const String &resourceGroup) | |
FreeTypeFont (const XMLAttributes &attributes) | |
virtual | ~FreeTypeFont () |
virtual void | updateFont () |
virtual void | writeXMLToStream_impl (XMLSerializer &xml_stream) const |
void | addFreeTypeFontProperties () |
Register all properties of this class. | |
void | free () |
Free all allocated font data. | |
Protected Attributes | |
ImagesetVector | d_glyphImages |
Imagesets that holds the glyphs for this font. | |
float | d_ptSize |
Point size of font. | |
bool | d_antiAliased |
True if the font should be rendered as anti-alaised by freeType. | |
FT_Face | d_fontFace |
FreeType-specific font handle. | |
RawDataContainer | d_fontData |
Font file data. | |
Friends | |
class | FontManager |
class | FontProperties::FreeTypePointSize |
class | FontProperties::FreeTypeAntialiased |
This implementation tries to provide maximal support for any kind of fonts supported by FreeType. It has been tested on outline font formats like TTF and PS as well as on bitmap font formats like PCF and FON.
Glyphs are rendered dynamically on demand, so a large font with lots of glyphs won't slow application startup time.
CEGUI::FreeTypeFont::FreeTypeFont | ( | const String & | name, | |
const String & | filename, | |||
const String & | resourceGroup | |||
) | [protected] |
Constructs a new semi-complete Font object. It is the responsability of the user to set up all remaining font parameters after constructing the Font object, and finally calling the load() method which will make font available for use. All font parameters that are not initialized are set to sensible default values.
name | The unique name that will be used to identify this Font. | |
fontname | The filename of the font file, which contains the font data. This can be a TrueType, PostScript, bitmap font etc file. | |
resourceGroup | Resource group identifier to be passed to the resource provider to load the font definition file. |
References addFreeTypeFontProperties().
CEGUI::FreeTypeFont::FreeTypeFont | ( | const XMLAttributes & | attributes | ) | [protected] |
Constructs a new semi-complete Font object. It is the responsability of the user to set up all remaining font parameters after constructing the Font object, and finally calling the load() method which will make font available for use. All font parameters that are not initialized are set to sensible default values.
name | The unique name that will be used to identify this Font. | |
fontname | The filename of the font file, which contains the font data. This can be a TrueType, PostScript, bitmap font etc file. | |
resourceGroup | Resource group identifier to be passed to the resource provider to load the font definition file. |
References addFreeTypeFontProperties().
CEGUI::FreeTypeFont::~FreeTypeFont | ( | ) | [protected, virtual] |
void CEGUI::FreeTypeFont::drawGlyphToBuffer | ( | argb_t * | buffer, | |
uint | buf_width | |||
) | [protected] |
Copy the current glyph data into buffer, which has a width of buf_width pixels (not bytes).
buffer | Memory buffer large enough to receive the imagery for the currently loaded glyph. | |
buf_width | Width of buffer in pixels (where each pixel is a argb_t). |
References d_fontFace.
Referenced by rasterize().
uint CEGUI::FreeTypeFont::getTextureSize | ( | CodepointMap::const_iterator | s, | |
CodepointMap::const_iterator | e | |||
) | [protected] |
Return the required texture size required to store imagery for the glyphs from s to e.
s | The first glyph in set | |
e | The last glyph in set |
References d_fontFace, CEGUI::Renderer::getMaxTextureSize(), CEGUI::System::getRenderer(), and CEGUI::System::getSingleton().
Referenced by rasterize().
void CEGUI::FreeTypeFont::load | ( | ) | [virtual] |
Complete font loading. If you create the font from an XML file, this method is invoked automatically after reading all the required data from the XMLAttributes object. If you create the font manually, it is your responsability to call this function as soon as you set up all the appropiate fields of the Font object.
Implements CEGUI::Font.
References CEGUI::Font::d_cp_map, CEGUI::Font::d_fileName, CEGUI::Font::d_name, d_ptSize, CEGUI::Font::d_resourceGroup, CEGUI::String::empty(), and updateFont().
void CEGUI::FreeTypeFont::rasterize | ( | utf32 | start_codepoint, | |
utf32 | end_codepoint | |||
) | [virtual] |
This function prepares a certain range of glyphs to be ready for displaying. This means that after returning from this function glyphs from d_cp_map[start_codepoint] to d_cp_map[end_codepoint] should have their d_image member set. If there is an error during rasterization of some glyph, it's okay to leave the d_image field set to NULL, in which case such glyphs will be skipped from display.
start_codepoint | The lowest codepoint that should be rasterized | |
end_codepoint | The highest codepoint that should be rasterized |
Reimplemented from CEGUI::Font.
References CEGUI::Renderer::createTexture(), d_antiAliased, CEGUI::Font::d_cp_map, d_fontFace, d_glyphImages, CEGUI::Font::d_name, CEGUI::Imageset::defineImage(), drawGlyphToBuffer(), CEGUI::Errors, CEGUI::Imageset::getImage(), CEGUI::System::getRenderer(), CEGUI::System::getSingleton(), CEGUI::Imageset::getTexture(), getTextureSize(), CEGUI::Texture::loadFromMemory(), and CEGUI::Texture::PF_RGBA.
void CEGUI::FreeTypeFont::updateFont | ( | ) | [protected, virtual] |
Update the font as required according to the current parameters.
Implements CEGUI::Font.
References CEGUI::Font::d_ascender, CEGUI::Font::d_autoScale, CEGUI::Font::d_cp_map, CEGUI::Font::d_descender, CEGUI::Font::d_fileName, d_fontData, d_fontFace, CEGUI::Font::d_height, CEGUI::Font::d_horzScaling, CEGUI::Font::d_name, d_ptSize, CEGUI::Font::d_resourceGroup, CEGUI::Font::d_vertScaling, CEGUI::String::empty(), free(), CEGUI::RawDataContainer::getDataPtr(), CEGUI::Font::getDefaultResourceGroup(), CEGUI::Renderer::getHorzScreenDPI(), CEGUI::System::getRenderer(), CEGUI::System::getResourceProvider(), CEGUI::System::getSingleton(), CEGUI::RawDataContainer::getSize(), CEGUI::Renderer::getVertScreenDPI(), CEGUI::ResourceProvider::loadRawDataContainer(), and CEGUI::Font::setMaxCodepoint().
Referenced by load().
void CEGUI::FreeTypeFont::writeXMLToStream_impl | ( | XMLSerializer & | xml_stream | ) | const [protected, virtual] |
Same as writeXMLToStream() but called from inside writeXMLToStream() so that derived classes may add their own attributes to stream.
xml_stream | Stream where xml data should be output. |
Implements CEGUI::Font.
References CEGUI::XMLSerializer::attribute(), d_antiAliased, and d_ptSize.