30 #include "CEGUI/Base.h"
31 #include "CEGUI/PropertySet.h"
32 #include "CEGUI/EventSet.h"
33 #include "CEGUI/String.h"
34 #include "CEGUI/XMLSerializer.h"
35 #include "CEGUI/FontGlyph.h"
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
58 class CEGUIEXPORT Font :
61 public AllocatedObject<Font>
65 static const argb_t DefaultColour;
68 static const String EventNamespace;
74 static const String EventRenderSizeChanged;
80 const String& getName()
const;
83 const String& getTypeName()
const;
86 const String& getFileName()
const;
99 bool isCodepointAvailable(utf32 cp)
const
100 {
return (d_cp_map.find(cp) != d_cp_map.end()); }
141 float drawText(GeometryBuffer& buffer,
const String& text,
142 const Vector2f& position,
const Rectf* clip_rect,
143 const ColourRect& colours,
const float space_extra = 0.0f,
144 const float x_scale = 1.0f,
const float y_scale = 1.0f)
const;
153 void setNativeResolution(
const Sizef& size);
163 const Sizef& getNativeResolution()
const;
192 virtual void notifyDisplaySizeChanged(
const Sizef& size);
206 float getLineSpacing(
float y_scale = 1.0f)
const
207 {
return d_height * y_scale; }
221 float getFontHeight(
float y_scale = 1.0f)
const
222 {
return (d_ascender - d_descender) * y_scale; }
236 float getBaseline(
float y_scale = 1.0f)
const
237 {
return d_ascender * y_scale; }
270 float getTextExtent(
const String& text,
float x_scale = 1.0f)
const;
300 float getTextAdvance(
const String& text,
float x_scale = 1.0f)
const;
325 size_t getCharAtPixel(
const String& text,
float pixel,
326 float x_scale = 1.0f)
const
327 {
return getCharAtPixel(text, 0, pixel, x_scale); }
357 size_t getCharAtPixel(
const String& text,
size_t start_char,
float pixel,
358 float x_scale = 1.0f)
const;
370 static void setDefaultResourceGroup(
const String& resourceGroup)
371 { d_defaultResourceGroup = resourceGroup; }
381 static const String& getDefaultResourceGroup()
382 {
return d_defaultResourceGroup; }
394 void writeXMLToStream(XMLSerializer& xml_stream)
const;
408 const FontGlyph* getGlyphData(utf32 codepoint)
const;
412 Font(
const String& name,
const String& type_name,
const String& filename,
414 const Sizef& native_res);
430 virtual void rasterise(utf32 start_codepoint, utf32 end_codepoint)
const;
433 virtual void updateFont() = 0;
436 virtual void writeXMLToStream_impl(XMLSerializer& xml_stream)
const = 0;
439 void addFontProperties();
442 virtual void onRenderSizeChanged(FontEventArgs& args);
449 void setMaxCodepoint(utf32 codepoint);
452 virtual const FontGlyph* findFontGlyph(
const utf32 codepoint)
const;
461 String d_resourceGroup;
463 static String d_defaultResourceGroup;
475 Sizef d_nativeResolution;
482 utf32 d_maxCodepoint;
497 uint* d_glyphPageLoaded;
500 typedef std::map<utf32, FontGlyph, std::less<utf32>
501 CEGUI_MAP_ALLOC(utf32, FontGlyph)> CodepointMap;
510 #if defined(_MSC_VER)
511 # pragma warning(pop)
515 #endif // end of guard _CEGUIFont_h_