Crazy Eddie's GUI System 0.8.7
FreeTypeFont.h
1/***********************************************************************
2 created: 3/6/2006
3 author: Andrew Zabolotny
4
5 purpose: Implementation of the Font class via the FreeType library
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUIFreeTypeFont_h_
30#define _CEGUIFreeTypeFont_h_
31
32#include "CEGUI/Font.h"
33#include "CEGUI/DataContainer.h"
34#include "CEGUI/BasicImage.h"
35
36#include <ft2build.h>
37#include FT_FREETYPE_H
38
39// Start of CEGUI namespace section
40namespace CEGUI
41{
53class FreeTypeFont : public Font
54{
55public:
95 FreeTypeFont(const String& font_name, const float point_size,
96 const bool anti_aliased, const String& font_filename,
97 const String& resource_group = "",
98 const AutoScaledMode auto_scaled = ASM_Disabled,
99 const Sizef& native_res = Sizef(640.0f, 480.0f),
100 const float specific_line_spacing = 0.0f);
101
104
106 float getPointSize() const;
107
109 bool isAntiAliased() const;
110
112 void setPointSize(const float point_size);
113
115 void setAntiAliased(const bool anti_alaised);
116
117protected:
133 void drawGlyphToBuffer(argb_t* buffer, uint buf_width) const;
134
144 uint getTextureSize(CodepointMap::const_iterator s,
145 CodepointMap::const_iterator e) const;
146
150 void free();
151
153 void initialiseFontGlyph(CodepointMap::iterator cp) const;
154
155 void initialiseGlyphMap();
156
157 // overrides of functions in Font base class.
158 const FontGlyph* findFontGlyph(const utf32 codepoint) const;
159 void rasterise(utf32 start_codepoint, utf32 end_codepoint) const;
161 void writeXMLToStream_impl (XMLSerializer& xml_stream) const;
162
166 float d_ptSize;
170 FT_Face d_fontFace;
174 typedef std::vector<Texture*
175 CEGUI_VECTOR_ALLOC(Texture*)> TextureVector;
178 typedef std::vector<BasicImage*
179 CEGUI_VECTOR_ALLOC(BasicImage*)> ImageVector;
181 mutable ImageVector d_glyphImages;
182#if defined(CEGUI_HAS_FREETYPE_TEMPORARY_BUFFER)
184 mutable uint d_temp_x, d_temp_y, d_temp_yb;
186 mutable Texture* d_temp_texture;
188 mutable argb_t* d_temp_mem_buffer;
189#endif
190};
191
192} // End of CEGUI namespace section
193
194#endif // end of guard _CEGUIFreeTypeFont_h_
Definition: BasicImage.h:43
internal class representing a single font glyph.
Definition: FontGlyph.h:44
Class that encapsulates a typeface.
Definition: Font.h:62
Implementation of the Font class interface using the FreeType library.
Definition: FreeTypeFont.h:54
std::vector< Texture *CEGUI_VECTOR_ALLOC(Texture *)> TextureVector
Type definition for TextureVector.
Definition: FreeTypeFont.h:175
bool isAntiAliased() const
return whether the freetype font is rendered anti-aliased.
void free()
Free all allocated font data.
FreeTypeFont(const String &font_name, const float point_size, const bool anti_aliased, const String &font_filename, const String &resource_group="", const AutoScaledMode auto_scaled=ASM_Disabled, const Sizef &native_res=Sizef(640.0f, 480.0f), const float specific_line_spacing=0.0f)
Constructor for FreeTypeFont based fonts.
bool d_antiAliased
True if the font should be rendered as anti-alaised by freeType.
Definition: FreeTypeFont.h:168
void setPointSize(const float point_size)
return the point size of the freetype font.
float getPointSize() const
return the point size of the freetype font.
float d_specificLineSpacing
If non-zero, the overridden line spacing that we're to report.
Definition: FreeTypeFont.h:164
const FontGlyph * findFontGlyph(const utf32 codepoint) const
finds FontGlyph in map and returns it, or 0 if none.
void rasterise(utf32 start_codepoint, utf32 end_codepoint) const
This function prepares a certain range of glyphs to be ready for displaying. This means that after re...
void initialiseFontGlyph(CodepointMap::iterator cp) const
initialise FontGlyph for given codepoint.
ImageVector d_glyphImages
collection of images defined for this font.
Definition: FreeTypeFont.h:181
void setAntiAliased(const bool anti_alaised)
return whether the freetype font is rendered anti-aliased.
FT_Face d_fontFace
FreeType-specific font handle.
Definition: FreeTypeFont.h:170
float d_ptSize
Point size of font.
Definition: FreeTypeFont.h:166
~FreeTypeFont()
Destructor.
void updateFont()
Update the font as needed, according to the current parameters.
void writeXMLToStream_impl(XMLSerializer &xml_stream) const
implementaion version of writeXMLToStream.
void drawGlyphToBuffer(argb_t *buffer, uint buf_width) const
Copy the current glyph data into buffer, which has a width of buf_width pixels (not bytes).
RawDataContainer d_fontData
Font file data.
Definition: FreeTypeFont.h:172
TextureVector d_glyphTextures
Textures that hold the glyph imagery for this font.
Definition: FreeTypeFont.h:177
uint getTextureSize(CodepointMap::const_iterator s, CodepointMap::const_iterator e) const
Return the required texture size required to store imagery for the glyphs from s to e.
void addFreeTypeFontProperties()
Register all properties of this class.
Class used as the databuffer for loading files throughout the library.
Definition: DataContainer.h:44
String class used within the GUI system.
Definition: String.h:64
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
Class used to create XML Document.
Definition: XMLSerializer.h:87
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
AutoScaledMode
Definition: Image.h:40
@ ASM_Disabled
No auto scaling takes place.
Definition: Image.h:42
uint32 argb_t
32 bit ARGB representation of a colour.
Definition: Colour.h:38