#include <arsfontengine.h>
Public Member Functions | |
| FontEngine (const std::string &sFontFileName, unsigned char FontSize) | |
| virtual | ~FontEngine (void) |
| Standard destructor. | |
| const int | GetFontSize (void) const |
| std::string | GetFontFilename (void) const |
| FT_BitmapGlyphRec * | RenderGlyph (const char Char) |
| FT_Glyph_Metrics * | GetMetrics (const char Char) |
Protected Attributes | |
| FT_Face | m_FontFace |
| The FreeType font face. | |
| std::map< char, FT_BitmapGlyphRec > | m_CachedGlyphMap |
| A cached map of the rendered glyphs. | |
| std::map< char, FT_Glyph_Metrics > | m_CachedMetricsMap |
| A cached map of the glyph metrics. | |
Static Protected Attributes | |
| FT_Library | m_FTLibrary |
| The FreeType library. | |
| bool | m_bFTLibraryLoaded = false |
| Indicates if the FreeType library has been loaded. | |
Private Attributes | |
| unsigned int | fontSize |
| std::string | fontFilename |
Definition at line 14 of file arsfontengine.h.
|
||||||||||||
|
Construct a new CFont object, using the specified font For most cases, there is no need to directly instantiate a CFontEngine object. CApplication provides a GetFontEngine() method which should be used
Definition at line 10 of file arsfontengine.cpp. References m_bFTLibraryLoaded, m_FontFace, m_FTLibrary, and tron.
00011 : fontSize( FontSize ) , fontFilename( sFontFileName ) 00012 { 00013 if (!m_bFTLibraryLoaded) 00014 { 00015 if (FT_Init_FreeType(&m_FTLibrary)) 00016 tron << "FontEngine::FontEngine : Unable to initialize FreeType library.\n"; 00017 m_bFTLibraryLoaded = true; 00018 } 00019 if (FT_New_Face(m_FTLibrary, sFontFileName.c_str(), 0, &m_FontFace)) 00020 tron << "FontEngine::FontEngine : Unable to create font face."; 00021 if (FT_Set_Char_Size(m_FontFace, 0, FontSize * 64, 0, 0)) 00022 tron << "FontEngine::FontEngine : Unable to set character size.\n"; 00023 } |
|
|
Standard destructor.
Definition at line 26 of file arsfontengine.cpp. References m_FontFace.
00027 {
00028 FT_Done_Face(m_FontFace);
00029 }
|
|
|
Definition at line 32 of file arsfontengine.h. References fontFilename. Referenced by Ars::Painter::Init().
00032 { return fontFilename; }
|
|
|
Definition at line 31 of file arsfontengine.h. References fontSize. Referenced by Ars::HPaint::GetFontSize(), and Ars::HPaint::GetTextSize().
00031 { return fontSize; }
|
|
|
Returns the metrics for a specified character
Definition at line 49 of file arsfontengine.cpp. References m_CachedMetricsMap, and m_FontFace. Referenced by Ars::HPaint::GetMaxFontHeight(), and Ars::HPaint::GetMetrics().
00050 {
00051 std::map<char, FT_Glyph_Metrics>::iterator glyphIter = m_CachedMetricsMap.find(Char);
00052 if (glyphIter == m_CachedMetricsMap.end())
00053 {
00054 if(FT_Load_Char(m_FontFace, Char, FT_LOAD_DEFAULT) == 0 )
00055 {
00056 glyphIter = m_CachedMetricsMap.insert(std::make_pair(Char, m_FontFace->glyph->metrics)).first;
00057 return &(glyphIter->second);
00058 }
00059 }
00060 return &(glyphIter->second);
00061 }
|
|
|
Renders the specified character
Definition at line 31 of file arsfontengine.cpp. References m_CachedGlyphMap, and m_FontFace. Referenced by Ars::HPaint::_TextOut().
00032 {
00033 std::map<char, FT_BitmapGlyphRec>::iterator glyphIter = m_CachedGlyphMap.find(Char);
00034 if (glyphIter == m_CachedGlyphMap.end())
00035 {
00036 if( FT_Load_Char(m_FontFace, Char, FT_LOAD_DEFAULT) == 0 )
00037 {
00038 FT_Glyph glyph;
00039 if( FT_Get_Glyph(m_FontFace->glyph, &glyph) == 0 && FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0, 1) == 0 )
00040 {
00041 glyphIter = m_CachedGlyphMap.insert(std::make_pair(Char, *reinterpret_cast<FT_BitmapGlyph>(glyph))).first;
00042 return &(glyphIter->second);
00043 }
00044 }
00045 }
00046 return &(glyphIter->second);
00047 }
|
|
|
Definition at line 18 of file arsfontengine.h. Referenced by GetFontFilename(). |
|
|
Definition at line 17 of file arsfontengine.h. Referenced by GetFontSize(). |
|
|
Indicates if the FreeType library has been loaded.
Definition at line 7 of file arsfontengine.cpp. Referenced by FontEngine(). |
|
|
A cached map of the rendered glyphs.
Definition at line 48 of file arsfontengine.h. Referenced by RenderGlyph(). |
|
|
A cached map of the glyph metrics.
Definition at line 49 of file arsfontengine.h. Referenced by GetMetrics(). |
|
|
The FreeType font face.
Definition at line 47 of file arsfontengine.h. Referenced by FontEngine(), GetMetrics(), RenderGlyph(), and ~FontEngine(). |
|
|
The FreeType library.
Definition at line 6 of file arsfontengine.cpp. Referenced by FontEngine(). |
1.3.3