This commit is contained in:
dborth 2009-08-12 05:39:01 +00:00
parent 74d1db9684
commit 4dd183302e
4 changed files with 18 additions and 9 deletions

View File

@ -26,7 +26,7 @@ static FT_Library ftLibrary; /**< FreeType FT_Library instance. */
static FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */ static FT_Face ftFace; /**< FreeType reusable FT_Face typographic object. */
static FT_GlyphSlot ftSlot; /**< FreeType reusable FT_GlyphSlot glyph container 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) void InitFreeType(uint8_t* fontBuffer, FT_Long bufferSize)
{ {

View File

@ -162,6 +162,8 @@
#include <wchar.h> #include <wchar.h>
#include <map> #include <map>
#define MAX_FONT_SIZE 100
/*! \struct ftgxCharData_ /*! \struct ftgxCharData_
* *
* Font face character glyph relevant data structure. * Font face character glyph relevant data structure.

View File

@ -618,10 +618,14 @@ class GuiText : public GuiElement
//!\param s Font size //!\param s Font size
void SetFontSize(int s); void SetFontSize(int s);
//!Sets the maximum width of the drawn texture image //!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 //!\param w Maximum width
void SetMaxWidth(int width); void SetMaxWidth(int width);
//!Enables/disables text scrolling
//!\param s Scrolling on/off
void SetScroll(int s); 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); void SetWrap(bool w, int width = 0);
//!Sets the font color //!Sets the font color
//!\param c Font color //!\param c Font color
@ -636,16 +640,16 @@ class GuiText : public GuiElement
//!Constantly called to draw the text //!Constantly called to draw the text
void Draw(); void Draw();
protected: protected:
char * origText; char * origText; //!< Original text data
wchar_t* text; //!< Unicode text value wchar_t* text; //!< Unicode text value
int size; //!< Font size int size; //!< Font size
int maxWidth; //!< Maximum width of the generated text object (for text wrapping) int maxWidth; //!< Maximum width of the generated text object (for text wrapping)
bool wrap; bool wrap; //!< Wrapping toggle
wchar_t* textDyn; wchar_t* textDyn; //!< Wrapped text value
int textScroll; int textScroll; //!< Scrolling toggle
int textScrollPos; int textScrollPos; //!< Current starting index of text string for scrolling
int textScrollInitialDelay; int textScrollInitialDelay; //!< Delay to wait before starting to scroll
int textScrollDelay; int textScrollDelay; //!< Scrolling speed
u16 style; //!< FreeTypeGX style attributes u16 style; //!< FreeTypeGX style attributes
GXColor color; //!< Font color GXColor color; //!< Font color
}; };

View File

@ -216,6 +216,9 @@ void GuiText::Draw()
int newSize = size*this->GetScale(); int newSize = size*this->GetScale();
if(newSize > MAX_FONT_SIZE)
newSize = MAX_FONT_SIZE;
if(newSize != currentSize) if(newSize != currentSize)
{ {
ChangeFontSize(newSize); ChangeFontSize(newSize);