A little clean in font system

This commit is contained in:
Edouard Dupin 2011-11-09 10:02:00 +01:00
parent 06f6cf283e
commit 172c5d31ec
5 changed files with 30 additions and 36 deletions

View File

@ -32,18 +32,6 @@
namespace ewol namespace ewol
{ {
// deprecated...
typedef enum {
FONT_MODE_NORMAL=0,
FONT_MODE_BOLD,
FONT_MODE_ITALIC,
FONT_MODE_BOLD_ITALIC,
FONT_MODE_NUMBER,
}fontMode_te;
//typedef char* Utf8Char_t;
// set default folder name of the font : // set default folder name of the font :
void SetFontFolder(etk::String folderName); void SetFontFolder(etk::String folderName);
void SetDefaultFont(etk::String fontName, int32_t size); void SetDefaultFont(etk::String fontName, int32_t size);

View File

@ -28,9 +28,26 @@
#undef __class__ #undef __class__
#define __class__ "ewol::OObject2DText" #define __class__ "ewol::OObject2DText"
ewol::OObject2DText::OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String) ewol::OObject2DText::OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg)
{ {
Text(x, y, FontName, size, mode, textColorFg, utf8String); m_textColorFg = textColorFg;
if (FontName == "") {
m_FontId = GetDefaultFontId();
} else {
EWOL_TODO("pas encore fait...");
//m_FontId = GetFontIdWithName(FontName);
m_FontId = -1;
return;
}
}
// open with default font ...
ewol::OObject2DText::OObject2DText(void)
{
m_textColorFg.red = 0.0;
m_textColorFg.green = 0.0;
m_textColorFg.blue = 0.0;
m_textColorFg.alpha = 1.0;
m_FontId = GetDefaultFontId();
} }
ewol::OObject2DText::~OObject2DText(void) ewol::OObject2DText::~OObject2DText(void)
@ -59,24 +76,14 @@ void ewol::OObject2DText::Draw(void)
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
} }
void ewol::OObject2DText::Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String) void ewol::OObject2DText::Text(float x, float y, const char* utf8String)
{ {
m_FontTextureId = 0; m_FontTextureId = 0;
m_coord.Clear(); m_coord.Clear();
m_coordTex.Clear(); m_coordTex.Clear();
// get font Name :
if (FontName == "") {
m_FontId = GetDefaultFontId();
} else {
EWOL_TODO("pas encore fait...");
//m_FontId = GetFontIdWithName(FontName);
return;
}
if (m_FontId == -1) { if (m_FontId == -1) {
EWOL_ERROR("Can not find the font with the name : " << FontName); EWOL_ERROR("Font Id is not corectly defined");
} }
EWOL_DEBUG("Font name : " << FontName << " id=" << m_FontId);
m_textColorFg = textColorFg;
coord2D_ts drawPosition; coord2D_ts drawPosition;
drawPosition.x = x; drawPosition.x = x;
drawPosition.y = y; drawPosition.y = y;

View File

@ -31,12 +31,13 @@ namespace ewol {
class OObject2DText :public ewol::OObject class OObject2DText :public ewol::OObject
{ {
public: public:
OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String); OObject2DText(etk::String FontName, int32_t size, color_ts textColorFg);
OObject2DText(void);
virtual ~OObject2DText(void); virtual ~OObject2DText(void);
public: public:
virtual void Draw(void); virtual void Draw(void);
// set a specific text // set a specific text
void Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String); void Text(float x, float y, const char* utf8String);
protected: protected:
int32_t m_FontId; //!< font internal ID int32_t m_FontId; //!< font internal ID
color_ts m_textColorFg; //!< text color ... color_ts m_textColorFg; //!< text color ...

View File

@ -70,12 +70,8 @@ ewol::Windows::Windows(void)
AddOObject(myOObject, "leftBoutton"); AddOObject(myOObject, "leftBoutton");
color_ts textColorFg; ewol::OObject2DText * myOObjectText = new ewol::OObject2DText();
textColorFg.red = .0; myOObjectText->Text(62, 2, "My Title ...");
textColorFg.green = .0;
textColorFg.blue = .0;
textColorFg.alpha = 1.0;
ewol::OObject2DText * myOObjectText = new ewol::OObject2DText(62, 2, "Monospace", 17 , FONT_MODE_BOLD, textColorFg, "My Title ...");
AddOObject(myOObjectText, "Title"); AddOObject(myOObjectText, "Title");
} }
} }

View File

@ -95,13 +95,15 @@ void ewol::Button::OnRegenerateDisplay(void)
textColorFg.blue = 0.0; textColorFg.blue = 0.0;
textColorFg.alpha = 1.0; textColorFg.alpha = 1.0;
ewol::OObject2DText * tmpText = new ewol::OObject2DText("", -1, textColorFg);
int32_t fontId = GetDefaultFontId(); int32_t fontId = GetDefaultFontId();
int32_t fontHeight = ewol::GetHeight(fontId); int32_t fontHeight = ewol::GetHeight(fontId);
int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str()); int32_t fontWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t posy = (m_size.y - fontHeight - 6)/2 + 3; int32_t posy = (m_size.y - fontHeight - 6)/2 + 3;
int32_t posx = (m_size.x - fontWidth - 6)/2 + 3; int32_t posx = (m_size.x - fontWidth - 6)/2 + 3;
ewol::OObject2DText * tmpText = new ewol::OObject2DText(posx, posy, "", -1, FONT_MODE_BOLD, textColorFg, m_label.c_str()); tmpText->Text(posx, posy, m_label.c_str());
AddOObject(tmpText, "BouttonText"); AddOObject(tmpText, "BouttonText");