37#include <freetype/freetype.h>
45 class IGUIEnvironment;
78 void preload(u32 char_index, FT_Face face,
CGUITTFont *parent, u32 font_size,
const FT_Int32 loadFlags);
84 video::IImage*
createGlyphImage(
const FT_Bitmap &bits, video::IVideoDriver *driver)
const;
136 bool preload =
true, u32 shadow = 0, u32
shadow_alpha = 255);
167 void setFontHinting(
const bool enable,
const bool enable_auto_hinting =
true);
170 virtual void draw(
const core::stringw& utext,
const core::rect<s32>& position,
171 video::SColor color,
bool hcenter=
false,
bool vcenter=
false,
172 const core::rect<s32>* clip=0)
override;
175 bool hcenter=
false,
bool vcenter=
false,
176 const core::rect<s32>* clip=0);
179 virtual core::dimension2du
getDimension(
const wchar_t* text)
const override;
191 virtual core::vector2di
getKerning(
const wchar_t thisLetter,
const wchar_t previousLetter)
const override;
223 core::dimension2d<u32>
getDimension(
const std::u32string& text)
const;
231 const bool transparency,
const bool preload);
238 load_flags = FT_LOAD_DEFAULT | FT_LOAD_RENDER;
244 load_flags |= FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO;
256 core::vector2di
getKerning(
const char32_t thisLetter,
const char32_t previousLetter)
const;
Definition enriched_string.h:28
Class representing a TrueType font.
Definition CGUITTFont.h:126
static CGUITTFont * createTTFont(IGUIEnvironment *env, SGUITTFace *face, u32 size, bool antialias=true, bool preload=true, u32 shadow=0, u32 shadow_alpha=255)
Definition CGUITTFont.cpp:370
video::IVideoDriver * Driver
Definition CGUITTFont.h:258
bool use_hinting
Definition CGUITTFont.h:215
u32 size
Definition CGUITTFont.h:217
virtual ~CGUITTFont()
Destructor.
Definition CGUITTFont.cpp:444
void setBatchLoadSize(u32 batch_size)
Sets the amount of glyphs to batch load.
Definition CGUITTFont.h:142
void setMonochrome(const bool flag)
Definition CGUITTFont.cpp:540
void setFontHinting(const bool enable, const bool enable_auto_hinting=true)
Definition CGUITTFont.cpp:546
virtual void draw(const core::stringw &utext, const core::rect< s32 > &position, video::SColor color, bool hcenter=false, bool vcenter=false, const core::rect< s32 > *clip=0) override
Draws some text and clips it to the specified rectangle if wanted.
Definition CGUITTFont.cpp:553
virtual void setInvisibleCharacters(const wchar_t *s) override
Define which characters should not be drawn by the font.
Definition CGUITTFont.cpp:966
bool use_auto_hinting
Definition CGUITTFont.h:216
FT_Face tt_face
Definition CGUITTFont.h:259
CGUITTGlyphPage * getLastGlyphPage() const
Definition CGUITTFont.cpp:479
CGUITTGlyphPage * createGlyphPage(const u8 pixel_mode)
Definition CGUITTFont.cpp:489
bool useMonochrome() const
Definition CGUITTFont.h:156
virtual core::dimension2du getDimension(const wchar_t *text) const override
Returns the dimension of a text string.
Definition CGUITTFont.cpp:729
void setFallback(gui::IGUIFont *font)
Set font that should be used for glyphs not present in ours.
Definition CGUITTFont.cpp:534
CGUITTFont(IGUIEnvironment *env)
Constructor.
Definition CGUITTFont.cpp:390
u32 getFontSize() const
Get the font size.
Definition CGUITTFont.h:145
u32 shadow_offset
Definition CGUITTFont.h:269
virtual void setKerningHeight(s32 kerning) override
Sets global kerning height for the font.
Definition CGUITTFont.cpp:911
bool use_monochrome
Definition CGUITTFont.h:214
u32 getLastGlyphPageIndex() const
Get the last glyph page's index.
Definition CGUITTFont.h:206
void update_load_flags()
Definition CGUITTFont.h:235
std::u32string InvisibleChars
Definition CGUITTFont.h:268
virtual core::vector2di getKerning(const wchar_t thisLetter, const wchar_t previousLetter) const override
Returns the distance between letters.
Definition CGUITTFont.cpp:916
u32 getWidthFromCharacter(char32_t c) const
Definition CGUITTFont.cpp:790
FT_Size_Metrics font_metrics
Definition CGUITTFont.h:260
u32 getGlyphIndexByChar(char32_t c) const
Returns (index + 1) of this->Glyphs Returns 0 if no such glyph is provided by the font.
Definition CGUITTFont.cpp:829
FT_Int32 load_flags
Definition CGUITTFont.h:261
s32 GlobalKerningWidth
Definition CGUITTFont.h:266
u32 getHeightFromCharacter(char32_t c) const
Definition CGUITTFont.cpp:809
virtual s32 getCharacterFromPos(const wchar_t *text, s32 pixel_x) const override
Calculates the index of the character in the text which is on a specific position.
Definition CGUITTFont.cpp:874
core::array< CGUITTGlyphPage * > Glyph_Pages
Definition CGUITTFont.h:263
void reset_images()
Definition CGUITTFont.cpp:455
u32 batch_load_size
Definition CGUITTFont.h:218
s32 GlobalKerningHeight
Definition CGUITTFont.h:267
core::array< SGUITTGlyph > Glyphs
Definition CGUITTFont.h:264
u32 shadow_alpha
Definition CGUITTFont.h:270
bool load(SGUITTFace *face, const u32 size, const bool antialias, const bool transparency, const bool preload)
Definition CGUITTFont.cpp:406
virtual void setKerningWidth(s32 kerning) override
Sets global kerning width for the font.
Definition CGUITTFont.cpp:906
u32 getLineHeight() const
Gets the overall font height, including a line gap of 1 px.
Definition CGUITTFont.h:250
void update_glyph_pages() const
Definition CGUITTFont.cpp:470
s32 getAscender() const
Definition CGUITTFont.h:211
std::u32string convertWCharToU32String(const wchar_t *const) const
Definition CGUITTFont.cpp:971
irr_ptr< gui::IGUIFont > fallback
Definition CGUITTFont.h:272
bool useAutoHinting() const
Definition CGUITTFont.h:149
bool useHinting() const
Check if the font hinting is enabled.
Definition CGUITTFont.h:152
Holds a sheet of glyphs.
Definition CGUITTFont.cpp:139
Definition fontengine.h:15
Definition clientmap.h:36
Definition CGUITTFont.h:101
static FT_Library getFreeTypeLibrary()
Definition CGUITTFont.cpp:55
std::string face_buffer
Definition CGUITTFont.h:111
static SGUITTFace * createFace(std::string &&buffer)
Definition CGUITTFont.cpp:84
static size_t n_faces
Definition CGUITTFont.h:105
static SGUITTFace * loadFace(const io::path &filename)
Definition CGUITTFont.cpp:96
FT_Face face
Definition CGUITTFont.h:117
static FT_Library freetype_library
Definition CGUITTFont.h:104
SGUITTFace(std::string &&buffer)
Definition CGUITTFont.cpp:66
~SGUITTFace()
Definition CGUITTFont.cpp:72
core::vector2di offset
The offset of glyph when drawn.
Definition CGUITTFont.h:93
video::IImage * createGlyphImage(const FT_Bitmap &bits, video::IVideoDriver *driver) const
Creates the IImage object from the FT_Bitmap.
Definition CGUITTFont.cpp:240
SGUITTGlyph()
Definition CGUITTFont.h:64
~SGUITTGlyph()
Definition CGUITTFont.h:70
void preload(u32 char_index, FT_Face face, CGUITTFont *parent, u32 font_size, const FT_Int32 loadFlags)
Preload the glyph.
Definition CGUITTFont.cpp:313
void unload()
Unloads the glyph.
Definition CGUITTFont.cpp:361
core::recti source_rect
The source rectangle for the glyph.
Definition CGUITTFont.h:90
bool isLoaded() const
If true, the glyph has been loaded.
Definition CGUITTFont.h:73
core::vector2di advance
Glyph advance information.
Definition CGUITTFont.h:96
u32 glyph_page
The page the glyph is on.
Definition CGUITTFont.h:87