19#ifndef HEADER_FONT_WITH_FACE_HPP
20#define HEADER_FONT_WITH_FACE_HPP
22#include "utils/cpp2011.hpp"
23#include "utils/leak_check.hpp"
24#include "utils/no_copy.hpp"
38#include <GlyphLayout.h>
39#include <dimension2d.h>
45const int BEARING = 64;
85 const core::rect<float>& destRect,
86 const core::rect<s32>& sourceRect,
87 const video::SColor*
const colors) = 0;
107 for (
const wchar_t* p = in_ptr; *p; ++p)
109 if (*p == L
'\r' || *p == L
'\n' || *p < (
wchar_t)32)
144 GlyphInfo(
unsigned int font_num = 0,
unsigned int glyph_idx = 0) :
193 std::map<wchar_t, GlyphInfo>::const_iterator n =
206 std::map<wchar_t, GlyphInfo>::const_iterator n =
219 std::map<wchar_t, GlyphInfo>::const_iterator n =
223 return n->second.glyph_index > 0;
249 virtual bool isBold()
const {
return false; }
251 const FontArea* getUnknownFontArea()
const;
254 const core::stringw& t);
272 virtual
void reset();
274 virtual core::dimension2d<u32>
getDimension(const core::stringw& text,
280 void render(const std::vector<gui::GlyphLayout>& gl,
281 const core::rect<s32>& position, const video::SColor& color,
282 bool hcenter,
bool vcenter, const core::rect<s32>* clip,
284 FontCharCollector* char_collector = NULL);
286 virtual
void drawText(const core::stringw& text,
287 const core::rect<s32>& position,
288 const video::SColor& color,
bool hcenter,
289 bool vcenter, const core::rect<s32>* clip,
291 FontCharCollector* char_collector = NULL);
293 void drawTextQuick(const core::stringw& text,
294 const core::rect<s32>& position,
295 const video::SColor& color,
bool hcenter,
bool vcenter,
296 const core::rect<s32>* clip,
298 FontCharCollector* char_collector = NULL);
308 bool* fallback_font)
const;
315 void insertGlyph(
unsigned font_number,
unsigned glyph_index);
321 virtual bool disableTextShaping()
const {
return false; }
325 virtual bool useColorGlyphPage()
const {
return false; }
This class will load a list of TTF files from FontManager, and save them inside m_ft_faces for FontWi...
Definition: face_ttf.hpp:57
This class stores settings when rendering fonts, used when instantiating irr::gui::ScalableFont.
Definition: font_settings.hpp:33
A class for STKTextBillboard to get font info to render billboard text.
Definition: font_with_face.hpp:77
virtual void collectChar(video::ITexture *texture, const core::rect< float > &destRect, const core::rect< s32 > &sourceRect, const video::SColor *const colors)=0
Collect the character info for billboard text.
An abstract class which contains functions which convert vector fonts into bitmap and render them in ...
Definition: font_with_face.hpp:72
const FontArea & getAreaFromCharacter(const wchar_t c, bool *fallback_font) const
Return the FontArea about a character.
Definition: font_with_face.cpp:453
virtual void reset()
Clear all the loaded characters, sub-class can do pre-loading of characters after this.
Definition: font_with_face.cpp:123
int getCharacterFromPos(const wchar_t *text, int pixel_x, FontSettings *font_settings=NULL) const
Calculate the index of the character in the text on a specific position.
Definition: font_with_face.cpp:524
int m_font_max_height
Used in vertical dimension calculation.
Definition: font_with_face.hpp:92
void setFallbackFontScale(float scale)
Set the scaling of fallback font.
Definition: font_with_face.hpp:138
virtual bool supportLazyLoadChar() const
Override it if sub-class should not do lazy loading characters.
Definition: font_with_face.hpp:236
std::vector< gui::GlyphLayout > text2GlyphsWithoutShaping(const core::stringw &t)
Convert text to drawable GlyphLayout without text shaping, used in digit font or debugging message.
Definition: font_with_face.cpp:1005
gui::IGUISpriteBank * getSpriteBank() const
Return the sprite bank.
Definition: font_with_face.hpp:305
const GlyphInfo & getGlyphInfo(wchar_t c) const
Get the GlyphInfo from m_character_glyph_info_map about a character.
Definition: font_with_face.hpp:204
virtual void init()
Initialize the font structure, but don't load glyph here.
Definition: font_with_face.cpp:86
void loadGlyphInfo(wchar_t c)
Convert a character to a glyph index in one of the font in m_face_ttf, it will find the first TTF tha...
Definition: font_with_face.cpp:144
float m_inverse_shaping
Used to undo the scale on text shaping, only need to take care of width.
Definition: font_with_face.hpp:181
void createNewGlyphPage()
Create a new glyph page by filling it with transparent content.
Definition: font_with_face.cpp:160
void setDPI()
Set the face dpi which is resolution-dependent.
Definition: font_with_face.cpp:404
float m_fallback_font_scale
Scaling for fallback font.
Definition: font_with_face.hpp:159
virtual unsigned int getScalingFactorTwo() const =0
Defined by sub-class about the scaling factor 2.
unsigned int m_used_width
The used width in glyph page.
Definition: font_with_face.hpp:171
int m_glyph_max_height
Used in top side bearing calculation.
Definition: font_with_face.hpp:95
void dumpGlyphPage()
Write the current glyph page in png inside current running directory.
Definition: font_with_face.cpp:392
std::set< wchar_t > m_new_char_holder
A temporary holder to store new characters to be inserted.
Definition: font_with_face.hpp:162
virtual bool isBold() const
Override it if sub-class has bold outline.
Definition: font_with_face.hpp:249
virtual int shapeOutline(FT_Outline *outline) const
Override it if any outline shaping is needed to be done before rendering the glyph into bitmap.
Definition: font_with_face.hpp:260
virtual core::dimension2d< u32 > getDimension(const core::stringw &text, FontSettings *font_settings=NULL)
Get the dimension of text with support to different FontSettings, it will also do checking for missin...
Definition: font_with_face.cpp:492
void addLazyLoadChar(wchar_t c)
Add a character into m_new_char_holder for lazy loading later.
Definition: font_with_face.hpp:233
void setFallbackFont(FontWithFace *face)
Set the fallback font for this font, so if some character is missing in this font,...
Definition: font_with_face.hpp:134
virtual float getScalingFactorOne() const =0
Defined by sub-class about the scaling factor 1.
void insertGlyph(unsigned font_number, unsigned glyph_index)
Render a glyph for a character into bitmap and save it into the glyph page.
Definition: font_with_face.cpp:181
void insertCharacters(const wchar_t *in_ptr, bool first_load=false)
Check characters to see if they are loaded in font, if not load them.
Definition: font_with_face.hpp:103
float getCharWidth(const FontArea &area, bool fallback, float scale) const
Return a character width.
Definition: font_with_face.cpp:944
unsigned int m_face_dpi
The dpi of this font.
Definition: font_with_face.hpp:177
unsigned int m_current_height
The current max height at current drawing line in glyph page.
Definition: font_with_face.hpp:168
bool loadedChar(wchar_t c) const
Test if a character has already been tried to be loaded.
Definition: font_with_face.hpp:191
unsigned int m_used_height
The used height in glyph page.
Definition: font_with_face.hpp:174
unsigned int getDPI() const
Return the dpi of this face.
Definition: font_with_face.hpp:311
virtual unsigned int getGlyphPageSize() const =0
Defined by sub-class about the texture size of glyph page, it should be a power of two.
void render(const std::vector< gui::GlyphLayout > &gl, const core::rect< s32 > &position, const video::SColor &color, bool hcenter, bool vcenter, const core::rect< s32 > *clip, FontSettings *font_settings, FontCharCollector *char_collector=NULL)
Render text and clip it to the specified rectangle if wanted, it will also do checking for missing ch...
Definition: font_with_face.cpp:562
bool supportChar(wchar_t c)
Tells whether a character is supported by all TTFs in m_face_ttf which is determined by GlyphInfo of ...
Definition: font_with_face.hpp:217
FontWithFace * m_fallback_font
Fallback font to use if some character isn't supported by this font.
Definition: font_with_face.hpp:156
void updateCharactersList()
Update the supported characters for this font if required.
Definition: font_with_face.cpp:346
gui::IGUISpriteBank * m_spritebank
Sprite bank to store each glyph.
Definition: font_with_face.hpp:165
std::map< wchar_t, GlyphInfo > m_character_glyph_info_map
Store a list of loaded and tested character to a GlyphInfo.
Definition: font_with_face.hpp:183
FaceTTF * m_face_ttf
FaceTTF to load glyph from.
Definition: font_with_face.hpp:153
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Glyph metrics for each glyph loaded.
Definition: face_ttf.hpp:37
Mapping of glyph index to a TTF in FaceTTF.
Definition: font_with_face.hpp:143
unsigned int glyph_index
Glyph index in the TTF, 0 means no such glyph.
Definition: font_with_face.hpp:149
unsigned int font_number
Index to a TTF in FaceTTF.
Definition: font_with_face.hpp:147