From 4dd183302ef997f16dc030fe5c750ec016b5b57e Mon Sep 17 00:00:00 2001 From: dborth Date: Wed, 12 Aug 2009 05:39:01 +0000 Subject: [PATCH] --- source/ngc/FreeTypeGX.cpp | 2 +- source/ngc/FreeTypeGX.h | 2 ++ source/ngc/gui/gui.h | 20 ++++++++++++-------- source/ngc/gui/gui_text.cpp | 3 +++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/source/ngc/FreeTypeGX.cpp b/source/ngc/FreeTypeGX.cpp index f96f28e..125476b 100644 --- a/source/ngc/FreeTypeGX.cpp +++ b/source/ngc/FreeTypeGX.cpp @@ -26,7 +26,7 @@ static FT_Library ftLibrary; /**< FreeType FT_Library instance. */ static FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ static FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container object. */ -FreeTypeGX *fontSystem[50]; +FreeTypeGX *fontSystem[MAX_FONT_SIZE+1]; void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize) { diff --git a/source/ngc/FreeTypeGX.h b/source/ngc/FreeTypeGX.h index 6afdc44..2ed6a82 100644 --- a/source/ngc/FreeTypeGX.h +++ b/source/ngc/FreeTypeGX.h @@ -162,6 +162,8 @@ #include #include +#define MAX_FONT_SIZE 100 + /*! \struct ftgxCharData_ * * Font face character glyph relevant data structure. diff --git a/source/ngc/gui/gui.h b/source/ngc/gui/gui.h index 020ccbc..ba57c5e 100644 --- a/source/ngc/gui/gui.h +++ b/source/ngc/gui/gui.h @@ -618,10 +618,14 @@ class GuiText : public GuiElement //!\param s Font size void SetFontSize(int s); //!Sets the maximum width of the drawn texture image - //!If the text exceeds this, it is wrapped to the next line //!\param w Maximum width void SetMaxWidth(int width); + //!Enables/disables text scrolling + //!\param s Scrolling on/off void SetScroll(int s); + //!Enables/disables text wrapping + //!\param w Wrapping on/off + //!\param width Maximum width (0 to disable) void SetWrap(bool w, int width = 0); //!Sets the font color //!\param c Font color @@ -636,16 +640,16 @@ class GuiText : public GuiElement //!Constantly called to draw the text void Draw(); protected: - char * origText; + char * origText; //!< Original text data wchar_t* text; //!< Unicode text value int size; //!< Font size int maxWidth; //!< Maximum width of the generated text object (for text wrapping) - bool wrap; - wchar_t* textDyn; - int textScroll; - int textScrollPos; - int textScrollInitialDelay; - int textScrollDelay; + bool wrap; //!< Wrapping toggle + wchar_t* textDyn; //!< Wrapped text value + int textScroll; //!< Scrolling toggle + int textScrollPos; //!< Current starting index of text string for scrolling + int textScrollInitialDelay; //!< Delay to wait before starting to scroll + int textScrollDelay; //!< Scrolling speed u16 style; //!< FreeTypeGX style attributes GXColor color; //!< Font color }; diff --git a/source/ngc/gui/gui_text.cpp b/source/ngc/gui/gui_text.cpp index 0e72186..2c8027c 100644 --- a/source/ngc/gui/gui_text.cpp +++ b/source/ngc/gui/gui_text.cpp @@ -216,6 +216,9 @@ void GuiText::Draw() int newSize = size*this->GetScale(); + if(newSize > MAX_FONT_SIZE) + newSize = MAX_FONT_SIZE; + if(newSize != currentSize) { ChangeFontSize(newSize);