Crazy Eddie's GUI System  0.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
FreeTypeFont.h
1 /***********************************************************************
2  filename: CEGUIFreeTypeFont.h
3  created: 3/6/2006
4  author: Andrew Zabolotny
5 
6  purpose: Implementation of the Font class via the FreeType library
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIFreeTypeFont_h_
31 #define _CEGUIFreeTypeFont_h_
32 
33 #include "CEGUI/Font.h"
34 #include "CEGUI/DataContainer.h"
35 #include "CEGUI/BasicImage.h"
36 
37 #include <ft2build.h>
38 #include FT_FREETYPE_H
39 
40 // Start of CEGUI namespace section
41 namespace CEGUI
42 {
54 class FreeTypeFont : public Font
55 {
56 public:
96  FreeTypeFont(const String& font_name, const float point_size,
97  const bool anti_aliased, const String& font_filename,
98  const String& resource_group = "",
99  const AutoScaledMode auto_scaled = ASM_Disabled,
100  const Sizef& native_res = Sizef(640.0f, 480.0f),
101  const float specific_line_spacing = 0.0f);
102 
104  ~FreeTypeFont();
105 
107  float getPointSize() const;
108 
110  bool isAntiAliased() const;
111 
113  void setPointSize(const float point_size);
114 
116  void setAntiAliased(const bool anti_alaised);
117 
118 protected:
134  void drawGlyphToBuffer(argb_t* buffer, uint buf_width) const;
135 
145  uint getTextureSize(CodepointMap::const_iterator s,
146  CodepointMap::const_iterator e) const;
147 
151  void free();
152 
154  void initialiseFontGlyph(CodepointMap::iterator cp) const;
155 
156  void initialiseGlyphMap();
157 
158  // overrides of functions in Font base class.
159  const FontGlyph* findFontGlyph(const utf32 codepoint) const;
160  void rasterise(utf32 start_codepoint, utf32 end_codepoint) const;
161  void updateFont();
162  void writeXMLToStream_impl (XMLSerializer& xml_stream) const;
163 
167  float d_ptSize;
171  FT_Face d_fontFace;
175  typedef std::vector<Texture*
176  CEGUI_VECTOR_ALLOC(Texture*)> TextureVector;
179  typedef std::vector<BasicImage*
180  CEGUI_VECTOR_ALLOC(BasicImage*)> ImageVector;
182  mutable ImageVector d_glyphImages;
183 };
184 
185 } // End of CEGUI namespace section
186 
187 #endif // end of guard _CEGUIFreeTypeFont_h_