00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _CEGUIFont_h_
00029 #define _CEGUIFont_h_
00030
00031 #include "CEGUIBase.h"
00032 #include "CEGUIPropertySet.h"
00033 #include "CEGUIString.h"
00034 #include "CEGUIXMLSerializer.h"
00035 #include "CEGUIFontGlyph.h"
00036
00037 #include <map>
00038
00039 #if defined(_MSC_VER)
00040 # pragma warning(push)
00041 # pragma warning(disable : 4251)
00042 #endif
00043
00044
00045 namespace CEGUI
00046 {
00058 class CEGUIEXPORT Font : public PropertySet
00059 {
00060 public:
00062 static const argb_t DefaultColour;
00063
00065 virtual ~Font();
00066
00068 const String& getName() const;
00069
00071 const String& getTypeName() const;
00072
00084 bool isCodepointAvailable(utf32 cp) const
00085 { return (d_cp_map.find(cp) != d_cp_map.end()); }
00086
00124 void drawText(GeometryBuffer& buffer, const String& text,
00125 const Vector2& position, const Rect* clip_rect,
00126 const ColourRect& colours, const float space_extra = 0.0f,
00127 const float x_scale = 1.0f, const float y_scale = 1.0f);
00128
00136 void setNativeResolution(const Size& size);
00137
00146 Size getNativeResolution() const;
00147
00156 void setAutoScaled(const bool auto_scaled);
00157
00166 bool isAutoScaled() const;
00167
00175 virtual void notifyDisplaySizeChanged(const Size& size);
00176
00189 float getLineSpacing(float y_scale = 1.0f) const
00190 { return d_height * y_scale; }
00191
00204 float getFontHeight(float y_scale = 1.0f) const
00205 { return (d_ascender - d_descender) * y_scale; }
00206
00219 float getBaseline(float y_scale = 1.0f) const
00220 { return d_ascender * y_scale; }
00221
00239 float getTextExtent(const String& text, float x_scale = 1.0f) const;
00240
00264 size_t getCharAtPixel(const String& text, float pixel,
00265 float x_scale = 1.0f) const
00266 { return getCharAtPixel(text, 0, pixel, x_scale); }
00267
00296 size_t getCharAtPixel(const String& text, size_t start_char, float pixel,
00297 float x_scale = 1.0f) const;
00298
00309 static void setDefaultResourceGroup(const String& resourceGroup)
00310 { d_defaultResourceGroup = resourceGroup; }
00311
00320 static const String& getDefaultResourceGroup()
00321 { return d_defaultResourceGroup; }
00322
00333 void writeXMLToStream(XMLSerializer& xml_stream) const;
00334
00347 const FontGlyph* getGlyphData(utf32 codepoint) const;
00348
00349 protected:
00351 Font(const String& name, const String& type_name, const String& filename,
00352 const String& resource_group, const bool auto_scaled,
00353 const float native_horz_res, const float native_vert_res);
00354
00369 virtual void rasterise(utf32 start_codepoint, utf32 end_codepoint) const;
00370
00372 virtual void updateFont() = 0;
00373
00375 virtual void writeXMLToStream_impl(XMLSerializer& xml_stream) const = 0;
00376
00378 void addFontProperties();
00379
00385 void setMaxCodepoint(utf32 codepoint);
00386
00388 String d_name;
00390 String d_type;
00392 String d_filename;
00394 String d_resourceGroup;
00396 static String d_defaultResourceGroup;
00397
00399 float d_ascender;
00401 float d_descender;
00403 float d_height;
00404
00406 bool d_autoScale;
00408 float d_nativeHorzRes;
00410 float d_nativeVertRes;
00412 float d_horzScaling;
00414 float d_vertScaling;
00415
00417 utf32 d_maxCodepoint;
00418
00432 uint* d_glyphPageLoaded;
00433
00435 typedef std::map<utf32, FontGlyph> CodepointMap;
00437 CodepointMap d_cp_map;
00438 };
00439
00440 }
00441
00442 #if defined(_MSC_VER)
00443 # pragma warning(pop)
00444 #endif
00445
00446
00447 #endif // end of guard _CEGUIFont_h_