Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 3/6/2006 00003 author: Andrew Zabolotny 00004 00005 purpose: Implementation of the Font class via the FreeType library 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIFreeTypeFont_h_ 00030 #define _CEGUIFreeTypeFont_h_ 00031 00032 #include "CEGUI/Font.h" 00033 #include "CEGUI/DataContainer.h" 00034 #include "CEGUI/BasicImage.h" 00035 00036 #include <ft2build.h> 00037 #include FT_FREETYPE_H 00038 00039 // Start of CEGUI namespace section 00040 namespace CEGUI 00041 { 00053 class FreeTypeFont : public Font 00054 { 00055 public: 00095 FreeTypeFont(const String& font_name, const float point_size, 00096 const bool anti_aliased, const String& font_filename, 00097 const String& resource_group = "", 00098 const AutoScaledMode auto_scaled = ASM_Disabled, 00099 const Sizef& native_res = Sizef(640.0f, 480.0f), 00100 const float specific_line_spacing = 0.0f); 00101 00103 ~FreeTypeFont(); 00104 00106 float getPointSize() const; 00107 00109 bool isAntiAliased() const; 00110 00112 void setPointSize(const float point_size); 00113 00115 void setAntiAliased(const bool anti_alaised); 00116 00117 protected: 00133 void drawGlyphToBuffer(argb_t* buffer, uint buf_width) const; 00134 00144 uint getTextureSize(CodepointMap::const_iterator s, 00145 CodepointMap::const_iterator e) const; 00146 00148 void addFreeTypeFontProperties(); 00150 void free(); 00151 00153 void initialiseFontGlyph(CodepointMap::iterator cp) const; 00154 00155 void initialiseGlyphMap(); 00156 00157 // overrides of functions in Font base class. 00158 const FontGlyph* findFontGlyph(const utf32 codepoint) const; 00159 void rasterise(utf32 start_codepoint, utf32 end_codepoint) const; 00160 void updateFont(); 00161 void writeXMLToStream_impl (XMLSerializer& xml_stream) const; 00162 00164 float d_specificLineSpacing; 00166 float d_ptSize; 00168 bool d_antiAliased; 00170 FT_Face d_fontFace; 00172 RawDataContainer d_fontData; 00174 typedef std::vector<Texture* 00175 CEGUI_VECTOR_ALLOC(Texture*)> TextureVector; 00177 mutable TextureVector d_glyphTextures; 00178 typedef std::vector<BasicImage* 00179 CEGUI_VECTOR_ALLOC(BasicImage*)> ImageVector; 00181 mutable ImageVector d_glyphImages; 00182 }; 00183 00184 } // End of CEGUI namespace section 00185 00186 #endif // end of guard _CEGUIFreeTypeFont_h_