From 07839a561fa876539484fdc44e68d3f17e20a89b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Sun, 12 May 2013 18:38:01 +0200 Subject: Unicode symbols for special characters * added support for special characters from original text bitmaps --- src/graphics/engine/text.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'src/graphics/engine/text.h') diff --git a/src/graphics/engine/text.h b/src/graphics/engine/text.h index 6bcc59b..b19a224 100644 --- a/src/graphics/engine/text.h +++ b/src/graphics/engine/text.h @@ -205,6 +205,20 @@ struct MultisizeFont : fileName(fn) {} }; +/** + * \enum SpecialChar + * \brief Special codes for certain characters + */ +enum SpecialChar +{ + CHAR_TAB = '\t', //! Tab character - : + CHAR_NEWLINE = '\n', //! Newline character - arrow pointing down and left + CHAR_DOT = 1, //! Single dot in the middle + CHAR_SQUARE = 2, //! Square + CHAR_SKIP_RIGHT = 5, //! Filled triangle pointing right + CHAR_SKIP_LEFT = 6 //! Filled triangle pointing left +}; + /** * \class CText * \brief Text rendering engine @@ -240,6 +254,12 @@ public: //! Flushes cached textures void FlushCache(); + //@{ + //! Tab size management + void SetTabSize(int tabSize); + int GetTabSize(); + //@} + //! Draws text (multi-format) void DrawText(const std::string &text, std::vector::iterator format, std::vector::iterator end, @@ -268,11 +288,11 @@ public: float GetHeight(FontType font, float size); //! Returns width of string (multi-format) - TEST_VIRTUAL float GetStringWidth(const std::string &text, - std::vector::iterator format, - std::vector::iterator end, float size); + TEST_VIRTUAL float GetStringWidth(const std::string& text, + std::vector::iterator format, + std::vector::iterator end, float size); //! Returns width of string (single font) - TEST_VIRTUAL float GetStringWidth(const std::string &text, FontType font, float size); + TEST_VIRTUAL float GetStringWidth(std::string text, FontType font, float size); //! Returns width of single character TEST_VIRTUAL float GetCharWidth(UTF8Char ch, FontType font, float size, float offset); @@ -290,6 +310,8 @@ public: //! Returns the most suitable position to a given offset (one font) int Detect(const std::string &text, FontType font, float size, float offset); + UTF8Char TranslateSpecialChar(int specialChar); + protected: CachedFont* GetOrOpenFont(FontType type, float size); CharTexture CreateCharTexture(UTF8Char ch, CachedFont* font); @@ -309,6 +331,7 @@ protected: std::string m_error; float m_defaultSize; + int m_tabSize; std::map m_fonts; -- cgit v1.2.3-1-g7c22