Class representing a TrueType font. More...
#include <CGUITTFont.h>
Public Member Functions | |
virtual | ~CGUITTFont () |
Destructor. | |
virtual void | setBatchLoadSize (u32 batch_size) |
Sets the amount of glyphs to batch load. | |
virtual void | setMaxPageTextureSize (const core::dimension2du &texture_size) |
Sets the maximum texture size for a page of glyphs. | |
virtual u32 | getFontSize () const |
Get the font size. | |
virtual bool | isTransparent () const |
Check the font's transparency. | |
virtual bool | useAutoHinting () const |
Check if the font auto-hinting is enabled. | |
virtual bool | useHinting () const |
Check if the font hinting is enabled. | |
virtual bool | useMonochrome () const |
Check if the font is being loaded as a monochrome font. | |
virtual void | setTransparency (const bool flag) |
Tells the font to allow transparency when rendering. | |
virtual void | setMonochrome (const bool flag) |
Tells the font to use monochrome rendering. | |
virtual void | setFontHinting (const bool enable, const bool enable_auto_hinting=true) |
Enables or disables font hinting. | |
virtual void | draw (const core::stringw &text, const core::rect< s32 > &position, video::SColor color, bool hcenter=false, bool vcenter=false, const core::rect< s32 > *clip=0) |
Draws some text and clips it to the specified rectangle if wanted. | |
void | draw (const EnrichedString &text, const core::rect< s32 > &position, bool hcenter=false, bool vcenter=false, const core::rect< s32 > *clip=0) |
virtual core::dimension2d< u32 > | getCharDimension (const wchar_t ch) const |
Returns the dimension of a character produced by this font. | |
virtual core::dimension2d< u32 > | getDimension (const wchar_t *text) const |
Returns the dimension of a text string. | |
virtual s32 | getCharacterFromPos (const wchar_t *text, s32 pixel_x) const |
Calculates the index of the character in the text which is on a specific position. | |
virtual void | setKerningWidth (s32 kerning) |
Sets global kerning width for the font. | |
virtual void | setKerningHeight (s32 kerning) |
Sets global kerning height for the font. | |
virtual s32 | getKerningWidth (const wchar_t *thisLetter=0, const wchar_t *previousLetter=0) const |
Gets kerning values (distance between letters) for the font. If no parameters are provided,. | |
virtual s32 | getKerningWidth (const char32_t thisLetter=0, const char32_t previousLetter=0) const |
virtual s32 | getKerningHeight () const |
Returns the distance between letters. | |
virtual void | setInvisibleCharacters (const wchar_t *s) |
Define which characters should not be drawn by the font. | |
CGUITTGlyphPage * | getLastGlyphPage () const |
Get the last glyph page if there's still available slots. | |
CGUITTGlyphPage * | createGlyphPage (const u8 &pixel_mode) |
Create a new glyph page texture. | |
u32 | getLastGlyphPageIndex () const |
Get the last glyph page's index. | |
void | setFallback (gui::IGUIFont *font) |
Set font that should be used for glyphs not present in ours. | |
virtual video::IImage * | createTextureFromChar (const char32_t &ch) |
Create corresponding character's software image copy from the font, so you can use this data just like any ordinary video::IImage. | |
virtual video::ITexture * | getPageTextureByIndex (const u32 &page_index) const |
This function is for debugging mostly. | |
virtual core::array< scene::ISceneNode * > | addTextSceneNode (const wchar_t *text, scene::ISceneManager *smgr, scene::ISceneNode *parent=0, const video::SColor &color=video::SColor(255, 0, 0, 0), bool center=false) |
Add a list of scene nodes generated by putting font textures on the 3D planes. | |
s32 | getAscender () const |
Static Public Member Functions | |
static CGUITTFont * | createTTFont (IGUIEnvironment *env, const io::path &filename, const u32 size, const bool antialias=true, const bool transparency=true, const u32 shadow=0, const u32 shadow_alpha=255) |
Creates a new TrueType font and returns a pointer to it. | |
Protected Attributes | |
bool | use_monochrome |
bool | use_transparency |
bool | use_hinting |
bool | use_auto_hinting |
u32 | size |
u32 | batch_load_size |
core::dimension2du | max_page_texture_size |
Private Member Functions | |
core::dimension2d< u32 > | getDimension (const std::u32string &text) const |
s32 | getCharacterFromPos (const std::u32string &text, s32 pixel_x) const |
std::u32string | convertWCharToU32String (const wchar_t *const) const |
CGUITTFont (IGUIEnvironment *env) | |
Constructor. | |
bool | load (const io::path &filename, const u32 size, const bool antialias, const bool transparency) |
void | reset_images () |
void | update_glyph_pages () const |
void | update_load_flags () |
u32 | getWidthFromCharacter (wchar_t c) const |
u32 | getWidthFromCharacter (char32_t c) const |
u32 | getHeightFromCharacter (wchar_t c) const |
u32 | getHeightFromCharacter (char32_t c) const |
u32 | getGlyphIndexByChar (wchar_t c) const |
u32 | getGlyphIndexByChar (char32_t c) const |
core::vector2di | getKerning (const wchar_t thisLetter, const wchar_t previousLetter) const |
core::vector2di | getKerning (const char32_t thisLetter, const char32_t previousLetter) const |
core::dimension2d< u32 > | getDimensionUntilEndOfLine (const wchar_t *p) const |
void | createSharedPlane () |
Private Attributes | |
irr::IrrlichtDevice * | Device |
gui::IGUIEnvironment * | Environment |
video::IVideoDriver * | Driver |
io::path | filename |
FT_Face | tt_face |
FT_Size_Metrics | font_metrics |
FT_Int32 | load_flags |
core::array< CGUITTGlyphPage * > | Glyph_Pages |
core::array< SGUITTGlyph > | Glyphs |
s32 | GlobalKerningWidth |
s32 | GlobalKerningHeight |
std::u32string | Invisible |
u32 | shadow_offset |
u32 | shadow_alpha |
gui::IGUIFont * | fallback |
Static Private Attributes | |
static FT_Library | c_library |
static std::map< io::path, SGUITTFace * > | c_faces |
static bool | c_libraryLoaded = false |
static scene::IMesh * | shared_plane_ptr_ = 0 |
static scene::SMesh | shared_plane_ |
Class representing a TrueType font.
|
virtual |
Destructor.
References c_faces, c_library, c_libraryLoaded, Driver, filename, Glyphs, and reset_images().
|
private |
Constructor.
References Driver, and setInvisibleCharacters().
Referenced by createTTFont().
|
virtual |
Add a list of scene nodes generated by putting font textures on the 3D planes.
NOTICE: Because we are considering adding texts into 3D world, all Y axis vectors are inverted.
References createSharedPlane(), Driver, font_metrics, getDimension(), getDimensionUntilEndOfLine(), getGlyphIndexByChar(), getKerning(), getWidthFromCharacter(), irr::gui::SGUITTGlyph::glyph_page, Glyph_Pages, Glyphs, irr::gui::SGUITTGlyph::offset, shared_plane_ptr_, irr::gui::SGUITTGlyph::source_rect, tt_face, update_glyph_pages(), and use_transparency.
|
private |
References p().
Referenced by draw(), getCharacterFromPos(), getDimension(), and setInvisibleCharacters().
CGUITTGlyphPage * irr::gui::CGUITTFont::createGlyphPage | ( | const u8 & | pixel_mode | ) |
Create a new glyph page texture.
pixel_mode | the pixel mode defined by FT_Pixel_Mode |
References irr::gui::CGUITTGlyphPage::available_slots, irr::gui::CGUITTGlyphPage::createPageTexture(), Driver, Glyph_Pages, max_page_texture_size, size, and tt_face.
Referenced by irr::gui::SGUITTGlyph::preload().
|
private |
References shared_plane_, and shared_plane_ptr_.
Referenced by addTextSceneNode().
|
virtual |
Create corresponding character's software image copy from the font, so you can use this data just like any ordinary video::IImage.
ch | The character you need |
References irr::gui::CGUITTGlyphPage::dirty, Driver, getGlyphIndexByChar(), irr::gui::SGUITTGlyph::glyph_page, Glyph_Pages, Glyphs, irr::gui::SGUITTGlyph::source_rect, irr::gui::CGUITTGlyphPage::texture, and irr::gui::CGUITTGlyphPage::updateTexture().
|
static |
Creates a new TrueType font and returns a pointer to it.
The pointer must be drop()'ed when finished.
env | The IGUIEnvironment the font loads out of. |
filename | The filename of the font. |
size | The size of the font glyphs in pixels. Since this is the size of the individual glyphs, the true height of the font may change depending on the characters used. |
antialias | set the use_monochrome (opposite to antialias) flag |
transparency | set the use_transparency flag |
References CGUITTFont(), c_library, c_libraryLoaded, filename, load(), shadow_alpha, shadow_offset, and size.
Referenced by FontEngine::initFont().
|
virtual |
Draws some text and clips it to the specified rectangle if wanted.
References draw().
Referenced by draw(), irr::gui::StaticText::draw(), Hud::drawLuaElements(), and GUIChatConsole::drawText().
void irr::gui::CGUITTFont::draw | ( | const EnrichedString & | text, |
const core::rect< s32 > & | position, | ||
bool | hcenter = false, | ||
bool | vcenter = false, | ||
const core::rect< s32 > * | clip = 0 ) |
References EnrichedString::c_str(), convertWCharToU32String(), Driver, fallback, font_metrics, EnrichedString::getColors(), getDimension(), getGlyphIndexByChar(), getKerning(), getWidthFromCharacter(), irr::gui::SGUITTGlyph::glyph_page, Glyph_Pages, Glyphs, Invisible, irr::gui::CGUITTGlyphPage::render_colors, irr::gui::CGUITTGlyphPage::render_positions, irr::gui::CGUITTGlyphPage::render_source_rects, shadow_alpha, shadow_offset, irr::gui::SGUITTGlyph::source_rect, irr::gui::CGUITTGlyphPage::texture, update_glyph_pages(), and use_transparency.
|
inline |
References font_metrics.
Referenced by TextDrawer::TextDrawer().
|
private |
|
virtual |
Calculates the index of the character in the text which is on a specific position.
References convertWCharToU32String(), and getCharacterFromPos().
Referenced by getCharacterFromPos().
|
virtual |
Returns the dimension of a character produced by this font.
References getHeightFromCharacter(), and getWidthFromCharacter().
|
private |
References getHeightFromCharacter(), getKerning(), getWidthFromCharacter(), and p().
|
virtual |
Returns the dimension of a text string.
References convertWCharToU32String(), and getDimension().
Referenced by addTextSceneNode(), draw(), getDimension(), and getDimensionUntilEndOfLine().
|
private |
References getDimension(), and p().
Referenced by addTextSceneNode().
|
inlinevirtual |
Get the font size.
References size.
Referenced by GUITable::setTable().
|
private |
References batch_load_size, Driver, irr::gui::SGUITTGlyph::glyph_page, Glyph_Pages, Glyphs, irr::gui::SGUITTGlyph::isLoaded, load_flags, irr::gui::SGUITTGlyph::preload(), size, and tt_face.
|
private |
References getGlyphIndexByChar().
Referenced by addTextSceneNode(), createTextureFromChar(), draw(), getGlyphIndexByChar(), getHeightFromCharacter(), getKerning(), getWidthFromCharacter(), and load().
|
inlineprivate |
References fallback, font_metrics, getGlyphIndexByChar(), and Glyphs.
|
inlineprivate |
References getHeightFromCharacter().
Referenced by getCharDimension(), getDimension(), and getHeightFromCharacter().
|
private |
References fallback, getGlyphIndexByChar(), GlobalKerningHeight, GlobalKerningWidth, size, and tt_face.
|
private |
References getKerning().
Referenced by addTextSceneNode(), draw(), getCharacterFromPos(), getDimension(), getKerning(), and getKerningWidth().
|
virtual |
Returns the distance between letters.
References GlobalKerningHeight.
|
virtual |
|
virtual |
Gets kerning values (distance between letters) for the font. If no parameters are provided,.
References getKerningWidth(), GlobalKerningWidth, and tt_face.
Referenced by getKerningWidth().
CGUITTGlyphPage * irr::gui::CGUITTFont::getLastGlyphPage | ( | ) | const |
Get the last glyph page if there's still available slots.
If not, it will return zero.
References irr::gui::CGUITTGlyphPage::available_slots, getLastGlyphPageIndex(), and Glyph_Pages.
Referenced by irr::gui::SGUITTGlyph::preload().
|
inline |
Get the last glyph page's index.
References Glyph_Pages.
Referenced by getLastGlyphPage(), and irr::gui::SGUITTGlyph::preload().
|
virtual |
This function is for debugging mostly.
If the page doesn't exist it returns zero.
page_index | Simply return the texture handle of a given page index. |
References Glyph_Pages.
|
inlineprivate |
References fallback, font_metrics, getGlyphIndexByChar(), and Glyphs.
|
inlineprivate |
References getWidthFromCharacter().
Referenced by addTextSceneNode(), draw(), getCharacterFromPos(), getCharDimension(), getDimension(), and getWidthFromCharacter().
|
inlinevirtual |
Check the font's transparency.
References use_transparency.
|
private |
References batch_load_size, c_faces, c_library, Device, Driver, irr::gui::SGUITTFace::face, irr::gui::SGUITTFace::face_buffer, irr::gui::SGUITTFace::face_buffer_size, filename, font_metrics, getGlyphIndexByChar(), Glyphs, size, tt_face, update_load_flags(), use_monochrome, and use_transparency.
Referenced by createTTFont().
|
private |
References Glyph_Pages, Glyphs, and update_load_flags().
Referenced by ~CGUITTFont(), setFontHinting(), setMonochrome(), and setTransparency().
|
inlinevirtual |
Sets the amount of glyphs to batch load.
References batch_load_size.
|
inline |
Set font that should be used for glyphs not present in ours.
References fallback.
|
virtual |
Enables or disables font hinting.
Default: Hinting and auto-hinting true.
enable | If false, font hinting is turned off. If true, font hinting is turned on. |
enable_auto_hinting | If true, FreeType uses its own auto-hinting algorithm. If false, it tries to use the algorithm specified by the font. |
References reset_images(), use_auto_hinting, and use_hinting.
|
virtual |
Define which characters should not be drawn by the font.
References convertWCharToU32String(), and Invisible.
Referenced by CGUITTFont().
|
virtual |
Sets global kerning height for the font.
References GlobalKerningHeight.
|
virtual |
Sets global kerning width for the font.
References GlobalKerningWidth.
|
inlinevirtual |
Sets the maximum texture size for a page of glyphs.
References max_page_texture_size.
|
virtual |
Tells the font to use monochrome rendering.
Default: false.
flag | If true, the font draws using a monochrome image. If false, the font uses a grayscale image. |
References reset_images(), and use_monochrome.
|
virtual |
Tells the font to allow transparency when rendering.
Default: true.
flag | If true, the font draws using transparency. |
References reset_images(), and use_transparency.
|
private |
References Glyph_Pages.
Referenced by addTextSceneNode(), and draw().
|
inlineprivate |
References load_flags, useAutoHinting(), useHinting(), and useMonochrome().
Referenced by load(), and reset_images().
|
inlinevirtual |
Check if the font auto-hinting is enabled.
Auto-hinting is FreeType's built-in font hinting engine.
References use_auto_hinting.
Referenced by update_load_flags().
|
inlinevirtual |
Check if the font hinting is enabled.
References use_hinting.
Referenced by update_load_flags().
|
inlinevirtual |
Check if the font is being loaded as a monochrome font.
The font can either be a 256 color grayscale font, or a 2 color monochrome font.
References use_monochrome.
Referenced by update_load_flags().
|
protected |
Referenced by getGlyphIndexByChar(), load(), and setBatchLoadSize().
|
staticprivate |
Referenced by ~CGUITTFont(), and load().
|
staticprivate |
Referenced by ~CGUITTFont(), createTTFont(), and load().
|
staticprivate |
Referenced by ~CGUITTFont(), and createTTFont().
|
private |
Referenced by load().
|
private |
Referenced by CGUITTFont(), ~CGUITTFont(), addTextSceneNode(), createGlyphPage(), createTextureFromChar(), draw(), getGlyphIndexByChar(), and load().
|
private |
|
private |
Referenced by draw(), getHeightFromCharacter(), getKerning(), getWidthFromCharacter(), and setFallback().
|
private |
Referenced by ~CGUITTFont(), createTTFont(), and load().
|
private |
Referenced by addTextSceneNode(), draw(), getAscender(), getHeightFromCharacter(), getWidthFromCharacter(), and load().
|
private |
Referenced by getKerning(), getKerningHeight(), and setKerningHeight().
|
private |
Referenced by getKerning(), getKerningWidth(), and setKerningWidth().
|
mutableprivate |
|
mutableprivate |
|
private |
Referenced by draw(), and setInvisibleCharacters().
|
private |
Referenced by getGlyphIndexByChar(), and update_load_flags().
|
protected |
Referenced by createGlyphPage(), and setMaxPageTextureSize().
|
private |
Referenced by createTTFont(), and draw().
|
private |
Referenced by createTTFont(), and draw().
|
staticprivate |
Referenced by createSharedPlane().
|
staticprivate |
Referenced by addTextSceneNode(), and createSharedPlane().
|
protected |
Referenced by createGlyphPage(), createTTFont(), getFontSize(), getGlyphIndexByChar(), getKerning(), and load().
|
private |
Referenced by addTextSceneNode(), createGlyphPage(), getGlyphIndexByChar(), getKerning(), getKerningWidth(), and load().
|
protected |
Referenced by setFontHinting(), and useAutoHinting().
|
protected |
Referenced by setFontHinting(), and useHinting().
|
protected |
Referenced by load(), setMonochrome(), and useMonochrome().
|
protected |
Referenced by addTextSceneNode(), draw(), isTransparent(), load(), and setTransparency().