33 #include "CEGUIBase.h"
34 #include "CEGUIPropertySet.h"
35 #include "CEGUIString.h"
36 #include "CEGUIRect.h"
37 #include "CEGUIVector.h"
38 #include "CEGUIColourRect.h"
39 #include "CEGUIXMLSerializer.h"
40 #include "CEGUIImage.h"
46 # pragma warning(push)
47 # pragma warning(disable : 4251)
56 namespace FontProperties
101 const Image* d_image;
117 FontGlyph (
float advance) : d_image (0), d_advance (advance)
124 FontGlyph (
float advance,
const Image *image) : d_image (image), d_advance (advance)
153 {
return d_image->
getWidth () * x_scale; }
160 {
return d_image->
getHeight () * y_scale; }
182 {
return d_advance * x_scale; }
189 { d_advance = advance; }
228 typedef std::map<utf32, FontGlyph> CodepointMap;
301 const String& resourceGroup =
"");
342 virtual void defineMapping (
const XMLAttributes& attributes);
348 virtual void updateFont () = 0;
354 size_t drawWrappedText (
const String& text,
const Rect& draw_area,
float z,
const Rect& clip_rect,
TextFormatting fmt,
const ColourRect& colours,
float x_scale = 1.0f,
float y_scale = 1.0f);
360 size_t getNextWord (
const String& in_string,
size_t start_idx,
String& out_string)
const;
366 void drawTextLine (
const String& text,
const Vector3& position,
const Rect& clip_rect,
const ColourRect& colours,
float x_scale = 1.0f,
float y_scale = 1.0f);
372 void drawTextLineJustified (
const String& text,
const Rect& draw_area,
const Vector3& position,
const Rect& clip_rect,
const ColourRect& colours,
float x_scale = 1.0f,
float y_scale = 1.0f);
378 float getWrappedTextExtent (
const String& text,
float wrapWidth,
float x_scale = 1.0f);
392 const FontGlyph* getGlyphData (utf32 codepoint);
399 void setMaxCodepoint (utf32 codepoint);
415 virtual void rasterize (utf32 start_codepoint, utf32 end_codepoint);
437 virtual void writeXMLToStream_impl (
XMLSerializer& xml_stream)
const = 0;
443 void addFontProperties ();
457 virtual void load () = 0;
470 bool isCodepointAvailable (utf32 cp)
const
471 {
return (d_cp_map.find(cp) != d_cp_map.end()); }
540 size_t drawText (
const String& text,
const Rect& draw_area,
float z,
const Rect& clip_rect,
TextFormatting fmt,
float x_scale = 1.0f,
float y_scale = 1.0f)
541 {
return drawText (text, draw_area, z, clip_rect, fmt,
ColourRect (DefaultColour, DefaultColour, DefaultColour, DefaultColour), x_scale, y_scale); }
569 void drawText (
const String& text,
const Rect& draw_area,
float z,
const Rect& clip_rect,
float x_scale = 1.0f,
float y_scale = 1.0f)
570 {
drawText (text, draw_area, z, clip_rect,
LeftAligned,
ColourRect (DefaultColour, DefaultColour, DefaultColour, DefaultColour), x_scale, y_scale); }
604 {
return drawText (text, draw_area, z, draw_area, fmt, colours, x_scale, y_scale); }
633 size_t drawText (
const String& text,
const Rect& draw_area,
float z,
TextFormatting fmt,
float x_scale = 1.0f,
float y_scale = 1.0f)
634 {
return drawText (text, draw_area, z, draw_area, fmt,
ColourRect (DefaultColour, DefaultColour, DefaultColour, DefaultColour), x_scale, y_scale); }
660 void drawText (
const String& text,
const Rect& draw_area,
float z,
float x_scale = 1.0f,
float y_scale = 1.0f)
661 {
drawText (text, draw_area, z, draw_area,
LeftAligned,
ColourRect (DefaultColour, DefaultColour, DefaultColour, DefaultColour), x_scale, y_scale); }
690 void drawText (
const String& text,
const Vector3& position,
const Rect& clip_rect,
const ColourRect& colours,
float x_scale = 1.0f,
float y_scale = 1.0f)
691 {
drawText (text,
Rect (position.d_x, position.d_y, position.d_x, position.d_y), position.d_z, clip_rect,
LeftAligned, colours, x_scale, y_scale); }
716 void drawText (
const String& text,
const Vector3& position,
const Rect& clip_rect,
float x_scale = 1.0f,
float y_scale = 1.0f)
717 {
drawText (text,
Rect (position.d_x, position.d_y, position.d_x, position.d_y), position.d_z, clip_rect,
LeftAligned,
ColourRect(DefaultColour, DefaultColour, DefaultColour, DefaultColour), x_scale, y_scale); }
729 virtual void setNativeResolution (
const Size& size);
741 virtual void notifyScreenResolution (
const Size& size);
758 float getLineSpacing (
float y_scale = 1.0f)
const
759 {
return d_height * y_scale; }
773 float getFontHeight (
float y_scale = 1.0f)
const
774 {
return (d_ascender - d_descender) * y_scale; }
788 float getBaseline (
float y_scale = 1.0f)
const
789 {
return d_ascender * y_scale; }
808 float getTextExtent (
const String& text,
float x_scale = 1.0f);
833 size_t getCharAtPixel (
const String& text,
float pixel,
float x_scale = 1.0f)
864 size_t getCharAtPixel (
const String& text,
size_t start_char,
float pixel,
float x_scale = 1.0f);
892 size_t getFormattedLineCount (
const String& text,
const Rect& format_area,
TextFormatting fmt,
float x_scale = 1.0f);
920 float getFormattedTextExtent (
const String& text,
const Rect& format_area,
TextFormatting fmt,
float x_scale = 1.0f);
933 static void setDefaultResourceGroup (
const String& resourceGroup)
934 { d_defaultResourceGroup = resourceGroup; }
945 static const String& getDefaultResourceGroup ()
946 {
return d_defaultResourceGroup; }
951 #if defined(_MSC_VER)
952 # pragma warning(pop)
956 #endif // end of guard _CEGUIFont_h_