system start to work

This commit is contained in:
Edouard Dupin 2012-08-22 21:40:51 +02:00
parent 229b1de48d
commit 3608a8f4df
10 changed files with 66 additions and 18 deletions

View File

@ -49,7 +49,7 @@ namespace ewol
etk::UString m_name;
uint32_t m_counter;
public:
Font(etk::UString fontName) :
Font(etk::UString fontFolder, etk::UString fontName) :
m_counter(1)
{
m_name = fontName;

View File

@ -90,12 +90,15 @@ void ewol::FreeTypeUnInit(void)
ewol::FontFreeType::FontFreeType(etk::UString fontName) :
Font(fontName)
ewol::FontFreeType::FontFreeType(etk::UString fontFolder, etk::UString fontName) :
Font(fontFolder, fontName)
{
m_init = false;
m_FileBuffer = NULL;
m_FileSize = 0;
etk::File myfile(fontName);
etk::UString tmpFileName = fontFolder + "/" + fontName;
etk::File myfile(tmpFileName, etk::FILE_TYPE_DATA);
if (false == myfile.Exist()) {
EWOL_ERROR("File Does not exist : " << myfile);
return;
@ -112,7 +115,7 @@ ewol::FontFreeType::FontFreeType(etk::UString fontName) :
// allocate data
m_FileBuffer = new FT_Byte[m_FileSize];
if (NULL == m_FileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << m_FileSize);
EWOL_ERROR("Error Memory allocation size=" << tmpFileName);
return;
}
// load data from the file :
@ -127,8 +130,9 @@ ewol::FontFreeType::FontFreeType(etk::UString fontName) :
EWOL_ERROR("... another error code means that the font file could not ... be opened or read, or simply that it is broken...");
} else {
// all OK
EWOL_INFO("load font : \"" << myfile << "\" ");
EWOL_INFO("load font : \"" << tmpFileName << "\" ");
//Display();
m_init = true;
}
}
@ -139,6 +143,7 @@ ewol::FontFreeType::~FontFreeType(void)
delete[] m_FileBuffer;
m_FileBuffer = NULL;
}
// must be deleted fftFace
}
int32_t ewol::FontFreeType::Draw(draw::Image& imageOut,
@ -147,6 +152,9 @@ int32_t ewol::FontFreeType::Draw(draw::Image& imageOut,
const etk::UString& unicodeString,
draw::Color& textColor)
{
if(false==m_init) {
return 0;
}
return 0;
}
@ -156,11 +164,17 @@ int32_t ewol::FontFreeType::Draw(draw::Image& imageOut,
const uniChar_t unicodeChar,
draw::Color& textColor)
{
if(false==m_init) {
return 0;
}
return 0;
}
Vector2D<float> ewol::FontFreeType::GetSize(int32_t fontSize, const etk::UString & unicodeString)
{
if(false==m_init) {
return Vector2D<float>(0,0);
}
Vector2D<float> outputSize(0,0);
return outputSize;
}
@ -172,6 +186,9 @@ int32_t ewol::FontFreeType::GetHeight(int32_t fontSize)
bool ewol::FontFreeType::GenerateBitmapFont(int32_t size, int32_t &height, ewol::Texture & texture, etk::Vector<freeTypeFontElement_ts> & listElement)
{
if(false==m_init) {
return false;
}
// get the pointer on the image :
draw::Image& myImage = texture.Get();
@ -280,7 +297,7 @@ bool ewol::FontFreeType::GenerateBitmapFont(int32_t size, int32_t &height, ewol:
for(int32_t j=0; j < tmpHeight;j++) {
for(int32_t i=0; i < tmpWidth; i++){
draw::Color tlpppp(0xFF,0xFF,0xFF,slot->bitmap.buffer[i + tmpWidth*j]);
EWOL_DEBUG(" plop : " << tlpppp);
//EWOL_DEBUG(" plop : " << tlpppp);
myImage.Set(Vector2D<int32_t>(tmpRowStartPos+i, tmpLineStartPos+j), tlpppp );
}
}
@ -312,6 +329,9 @@ bool ewol::FontFreeType::GenerateBitmapFont(int32_t size, int32_t &height, ewol:
void ewol::FontFreeType::Display(void)
{
if(false==m_init) {
return;
}
EWOL_INFO(" nuber of glyph = " << (int)m_fftFace->num_glyphs);
if ((FT_FACE_FLAG_SCALABLE & m_fftFace->face_flags) != 0) {
EWOL_INFO(" flags = FT_FACE_FLAG_SCALABLE (enable)");

View File

@ -40,9 +40,10 @@ namespace ewol
FT_Byte * m_FileBuffer;
int32_t m_FileSize;
FT_Face m_fftFace;
bool m_init;
void Display(void);
public:
FontFreeType(etk::UString fontName);
FontFreeType(etk::UString fontFolder, etk::UString fontName);
~FontFreeType(void);
int32_t Draw(draw::Image& imageOut,
int32_t fontSize,

View File

@ -104,18 +104,17 @@ int32_t ewol::font::GetDefaultSize(void)
ewol::Font* ewol::font::Keep(etk::UString fontName)
{
etk::UString tmpFileName = l_folderName + "/" + fontName;
for (int32_t iii=l_fontList.Size()-1; iii>=0; iii--) {
if (l_fontList[iii] != NULL) {
if(l_fontList[iii]->HasName(tmpFileName)) {
if(l_fontList[iii]->HasName(fontName)) {
l_fontList[iii]->Increment();
return l_fontList[iii];
}
}
}
ewol::FontFreeType* tmpResources = new ewol::FontFreeType(tmpFileName);
ewol::FontFreeType* tmpResources = new ewol::FontFreeType(l_folderName, fontName);
if (NULL == tmpResources) {
EWOL_ERROR("allocation error of a resource Font : " << tmpFileName);
EWOL_ERROR("allocation error of a resource Font : " << l_folderName << "/" << fontName);
return NULL;
}
l_fontList.PushBack(tmpResources);
@ -144,18 +143,20 @@ void ewol::font::Release(ewol::Font*& object)
ewol::TexturedFont* ewol::font::TexturedKeep(etk::UString fontName, int32_t size)
{
etk::UString tmpFileName = l_folderName + "/" + fontName;
EWOL_VERBOSE("Textured font : try to find ... \"" << fontName << "\"");
for (int32_t iii=l_fontTexturedList.Size()-1; iii>=0; iii--) {
if (l_fontTexturedList[iii] != NULL) {
if(l_fontTexturedList[iii]->HasName(tmpFileName, size)) {
if(l_fontTexturedList[iii]->HasName(fontName, size)) {
EWOL_VERBOSE(" ==> Find prellocated");
l_fontTexturedList[iii]->Increment();
return l_fontTexturedList[iii];
}
}
}
ewol::TexturedFont* tmpResources = new ewol::TexturedFont(tmpFileName, size);
EWOL_VERBOSE(" ==> Create new One");
ewol::TexturedFont* tmpResources = new ewol::TexturedFont(fontName, size);
if (NULL == tmpResources) {
EWOL_ERROR("allocation error of a resource textured Font : " << tmpFileName);
EWOL_ERROR("allocation error of a resource textured Font : " << fontName);
return NULL;
}
l_fontTexturedList.PushBack(tmpResources);

View File

@ -37,6 +37,22 @@ ewol::TexturedFont::TexturedFont(etk::UString fontName, int32_t size) :
if (NULL == m_font) {
return;
}
// set the bassic charset:
m_listElement.Clear();
freeTypeFontElement_ts tmpchar1;
tmpchar1.unicodeCharVal = 0;
m_listElement.PushBack(tmpchar1);
// TODO : dynamic generation of this : expected minimum of 0x20 => 0x7F ....
for (int32_t iii=0x20; iii<0xFF; iii++) {
freeTypeFontElement_ts tmpchar;
tmpchar.unicodeCharVal = iii;
m_listElement.PushBack(tmpchar);
if (0x7F == iii) {
iii = 0x9F;
}
}
// initilize the texture ...
// TODO : Do a better methode that not initialize with a stupid language ... like now ...
m_font->GenerateBitmapFont(m_size, m_height, m_texture, m_listElement);

View File

@ -163,7 +163,11 @@ void ewol::Button::OnDraw(DrawProperty& displayProp)
void ewol::Button::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectDecoration.Clear();
m_oObjectText.Clear();
if (NULL != m_oObjectImage) {
m_oObjectImage->Clear();
}
int32_t tmpSizeX = m_minSize.x;
int32_t tmpSizeY = m_minSize.y;
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;

View File

@ -136,7 +136,8 @@ void ewol::ButtonColor::OnDraw(DrawProperty& displayProp)
void ewol::ButtonColor::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectDecoration.Clear();
m_oObjectText.Clear();
int32_t tmpSizeX = m_minSize.x;
int32_t tmpSizeY = m_minSize.y;
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;

View File

@ -105,6 +105,8 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectDecoration.Clear();
m_oObjectText.Clear();
int32_t borderWidth = 2;

View File

@ -114,6 +114,8 @@ void ewol::Entry::OnDraw(DrawProperty& displayProp)
void ewol::Entry::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectDecoration.Clear();
m_oObjectText.Clear();
UpdateTextPosition();
int32_t tmpSizeX = m_minSize.x;

View File

@ -86,6 +86,7 @@ void ewol::Label::OnDraw(DrawProperty& displayProp)
void ewol::Label::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectText.Clear();
int32_t paddingSize = 3;
int32_t tmpOriginX = 0;