From c3838996f329fb957c498990c0ed3e248648b38b Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 13 Nov 2012 22:50:35 +0100 Subject: [PATCH] [DEV] change the internal system of register font ==> use system font --- sources/appl/Buffer/Buffer.h | 9 --- sources/appl/Buffer/BufferEmpty.cpp | 22 ++----- sources/appl/Buffer/BufferEmpty.h | 10 ---- sources/appl/Buffer/BufferText.cpp | 62 ++++++-------------- sources/appl/Buffer/BufferText.h | 10 ---- sources/appl/Gui/CodeView.cpp | 90 +++++------------------------ sources/appl/Gui/CodeView.h | 22 +------ sources/appl/Gui/MainWindows.cpp | 13 +---- sources/appl/init.cpp | 5 +- 9 files changed, 45 insertions(+), 198 deletions(-) diff --git a/sources/appl/Buffer/Buffer.h b/sources/appl/Buffer/Buffer.h index 5dc37de..43f5853 100644 --- a/sources/appl/Buffer/Buffer.h +++ b/sources/appl/Buffer/Buffer.h @@ -85,17 +85,8 @@ class Buffer { public: virtual void GetInfo(infoStatBuffer_ts &infoToUpdate) {}; virtual void SetLineDisplay(uint32_t lineNumber) {}; - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText, ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) - - #else - virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, - ewol::TEXT_DISPLAY_TYPE& OOTextBold, - ewol::TEXT_DISPLAY_TYPE& OOTextItalic, - ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic, - ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) - #endif { return ERR_NONE; } diff --git a/sources/appl/Buffer/BufferEmpty.cpp b/sources/appl/Buffer/BufferEmpty.cpp index 67adb08..1552c6c 100644 --- a/sources/appl/Buffer/BufferEmpty.cpp +++ b/sources/appl/Buffer/BufferEmpty.cpp @@ -67,25 +67,13 @@ BufferEmpty::~BufferEmpty(void) * @return --- * */ -#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOText, ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) -#else -int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, - ewol::TEXT_DISPLAY_TYPE& OOTextBold, - ewol::TEXT_DISPLAY_TYPE& OOTextItalic, - ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic, - ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) -#endif { // Get color : Colorize *myColor = NULL; - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - int32_t letterHeight = OOText.GetHeight(); - #else - int32_t letterHeight = OOTextNormal.GetHeight(); - #endif + int32_t letterHeight = OOText.GetHeight(); etk::Vector2D textPos; textPos.x = 20; @@ -100,8 +88,8 @@ int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, OOText.SetItalic(false); OOText.Text(textPos, tmpDisplay); #else - OOTextBold.SetColor(myColor->GetFG()); - OOTextBold.Text(textPos, tmpDisplay); + OOText.SetColor(myColor->GetFG()); + OOText.Text(textPos, tmpDisplay, ewol::font::Bold); #endif myColor = ColorizeManager::Get("commentDoxygen"); @@ -113,8 +101,8 @@ int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, OOText.SetColor(myColor->GetFG()); OOText.Text(textPos, tmpDisplay); #else - OOTextNormal.SetColor(myColor->GetFG()); - OOTextNormal.Text(textPos, tmpDisplay); + OOText.SetColor(myColor->GetFG()); + OOText.Text(textPos, tmpDisplay, ewol::font::Regular); #endif OOColored.SetColor(draw::color::white); diff --git a/sources/appl/Buffer/BufferEmpty.h b/sources/appl/Buffer/BufferEmpty.h index fdbb19f..a39df77 100644 --- a/sources/appl/Buffer/BufferEmpty.h +++ b/sources/appl/Buffer/BufferEmpty.h @@ -32,18 +32,8 @@ class BufferEmpty : public Buffer { public: BufferEmpty(void); virtual ~BufferEmpty(void); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText, ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); - #else - int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, - ewol::TEXT_DISPLAY_TYPE& OOTextBold, - ewol::TEXT_DISPLAY_TYPE& OOTextItalic, - ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic, - ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); - - #endif - }; diff --git a/sources/appl/Buffer/BufferText.cpp b/sources/appl/Buffer/BufferText.cpp index ede9c03..88dd1d5 100644 --- a/sources/appl/Buffer/BufferText.cpp +++ b/sources/appl/Buffer/BufferText.cpp @@ -277,32 +277,18 @@ int32_t BufferText::GetNumberOfLine(void) * @return * */ -#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText, ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) -#else -int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, - ewol::TEXT_DISPLAY_TYPE& OOTextBold, - ewol::TEXT_DISPLAY_TYPE& OOTextItalic, - ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic, - ewol::OObject2DColored& OOColored, - int32_t offsetX, int32_t offsetY, - int32_t sizeX, int32_t sizeY) -#endif { int32_t selStart, selEnd, selRectStart, selRectEnd; bool selIsRect; int32_t selHave; - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - int32_t letterWidth = OOText.GetSize("A").x; - int32_t letterHeight = OOText.GetHeight(); - #else - int32_t letterWidth = OOTextNormal.GetSize("A").x; - int32_t letterHeight = OOTextNormal.GetHeight(); - #endif + int32_t letterWidth = OOText.GetSize("A").x; + int32_t letterHeight = OOText.GetHeight(); + int32_t displayStartLineId = offsetY / letterHeight - 1; displayStartLineId = etk_max(0, displayStartLineId); int32_t y = - offsetY + displayStartLineId*letterHeight; @@ -330,9 +316,6 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, draw::Color & myColorSpace = ColorizeManager::Get(COLOR_CODE_SPACE); draw::Color & myColorTab = ColorizeManager::Get(COLOR_CODE_TAB); Colorize * selectColor = NULL; - #ifndef APPL_BUFFER_FONT_DISTANCE_FIELD - ewol::TEXT_DISPLAY_TYPE* OOTextSelected = NULL; - #endif int mylen = m_EdnBuf.Size(); int32_t x_base=nbColoneForLineNumber*letterWidth; int32_t idX = 0; @@ -362,13 +345,8 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, y -= letterHeight; OOColored.clippingDisable(); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - OOText.clippingDisable(); - DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); - #else - OOTextNormal.clippingDisable(); - DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); - #endif + OOText.clippingDisable(); + DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER; clipping_ts drawClipping; @@ -383,14 +361,7 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, drawClippingTextArea.w = sizeX - drawClipping.x; drawClippingTextArea.h = sizeY; - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - OOText.clippingSet(drawClippingTextArea); - #else - OOTextNormal.clippingSet(drawClippingTextArea); - OOTextBold.clippingSet(drawClippingTextArea); - OOTextItalic.clippingSet(drawClippingTextArea); - OOTextBoldItalic.clippingSet(drawClippingTextArea); - #endif + OOText.clippingSet(drawClippingTextArea); OOColored.clippingSet(drawClippingTextArea); // Clear the line intexation : @@ -463,25 +434,26 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, myStringToDisplay = displayChar; drawSize = OOText.Text(textPos, myStringToDisplay); #else + ewol::font::mode_te tmpMode = ewol::font::Regular; if (true == selectColor->GetItalic() ) { if (true == selectColor->GetBold() ) { - OOTextSelected = &OOTextBoldItalic; + tmpMode = ewol::font::BoldItalic; } else { - OOTextSelected = &OOTextItalic; + tmpMode = ewol::font::Italic; } } else { if (true == selectColor->GetBold() ) { - OOTextSelected = &OOTextBold; + tmpMode = ewol::font::Bold; } else { - OOTextSelected = &OOTextNormal; + tmpMode = ewol::font::Regular; } } - tmpElementProperty.m_ySize = OOTextSelected->GetHeight(); + tmpElementProperty.m_ySize = OOText.GetHeight(); //tmpElementProperty.m_yOffset += tmpElementProperty.m_ySize; - OOTextSelected->SetColor(selectColor->GetFG()); + OOText.SetColor(selectColor->GetFG()); // TODO : Remove this unreallistic leak of time myStringToDisplay = displayChar; - drawSize = OOTextSelected->Text(textPos, myStringToDisplay); + drawSize = OOText.Text(textPos, myStringToDisplay, tmpMode); #endif //APPL_DEBUG("add element : " << tmpElementProperty.m_yOffset << "," << tmpElementProperty.m_xOffset); m_elmentList.PushBack(tmpElementProperty); @@ -516,9 +488,9 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); OOText.clippingEnable(); #else - OOTextNormal.clippingDisable(); - DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); - OOTextNormal.clippingEnable(); + OOText.clippingDisable(); + DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y); + OOText.clippingEnable(); #endif OOColored.clippingEnable(); // add elements : diff --git a/sources/appl/Buffer/BufferText.h b/sources/appl/Buffer/BufferText.h index 50c9352..645b80c 100644 --- a/sources/appl/Buffer/BufferText.h +++ b/sources/appl/Buffer/BufferText.h @@ -54,20 +54,10 @@ class BufferText : public Buffer { void GetInfo(infoStatBuffer_ts &infoToUpdate); void SetLineDisplay(uint32_t lineNumber); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText, ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); - #else - int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOTextNormal, - ewol::TEXT_DISPLAY_TYPE& OOTextBold, - ewol::TEXT_DISPLAY_TYPE& OOTextItalic, - ewol::TEXT_DISPLAY_TYPE& OOTextBoldItalic, - ewol::OObject2DColored& OOColored, - int32_t offsetX, int32_t offsetY, - int32_t sizeX, int32_t sizeY); - #endif void AddChar(uniChar_t unicodeData); void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); void MouseSelectFromCursorTo(etk::Vector2D pos); diff --git a/sources/appl/Gui/CodeView.cpp b/sources/appl/Gui/CodeView.cpp index fac8be6..1f49352 100644 --- a/sources/appl/Gui/CodeView.cpp +++ b/sources/appl/Gui/CodeView.cpp @@ -78,13 +78,11 @@ void CodeView::Init(void) ShortCutAdd("ctrl+shift+a", ednMsgGuiSelect, "NONE"); } -#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - CodeView::CodeView(etk::UString fontName, int32_t fontSize) : - m_OObjectText(fontName, fontSize) - { - Init(); - } -#endif +CodeView::CodeView(etk::UString fontName, int32_t fontSize) : + m_OObjectText(fontName, fontSize) +{ + Init(); +} CodeView::CodeView(void) { @@ -127,11 +125,7 @@ bool CodeView::CalculateMinSize(void) void CodeView::CalculateMaxSize(void) { m_maxSize.x = 2048; - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - int32_t letterHeight = m_OObjectText.GetHeight(); - #else - int32_t letterHeight = m_OObjectTextNormal.GetHeight(); - #endif + int32_t letterHeight = m_OObjectText.GetHeight(); m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight; } @@ -139,14 +133,7 @@ void CodeView::CalculateMaxSize(void) void CodeView::OnDraw(ewol::DrawProperty& displayProp) { m_OObjectsColored.Draw(); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - m_OObjectText.Draw(); - #else - m_OObjectTextNormal.Draw(); - m_OObjectTextBold.Draw(); - m_OObjectTextItalic.Draw(); - m_OObjectTextBoldItalic.Draw(); - #endif + m_OObjectText.Draw(); WidgetScrooled::OnDraw(displayProp); } @@ -158,14 +145,7 @@ void CodeView::OnRegenerateDisplay(void) // For the scrooling windows CalculateMaxSize(); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - m_OObjectText.Clear(); - #else - m_OObjectTextNormal.Clear(); - m_OObjectTextBold.Clear(); - m_OObjectTextItalic.Clear(); - m_OObjectTextBoldItalic.Clear(); - #endif + m_OObjectText.Clear(); m_OObjectsColored.Clear(); @@ -178,18 +158,9 @@ void CodeView::OnRegenerateDisplay(void) } // else : nothing to do ... // generate the objects : - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - BufferManager::Get(m_bufferID)->Display(m_OObjectText, - m_OObjectsColored, - m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y); - #else - BufferManager::Get(m_bufferID)->Display(m_OObjectTextNormal, - m_OObjectTextBold, - m_OObjectTextItalic, - m_OObjectTextBoldItalic, - m_OObjectsColored, - m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y); - #endif + BufferManager::Get(m_bufferID)->Display(m_OObjectText, + m_OObjectsColored, + m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y); // set the current size of the windows SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize()); @@ -435,41 +406,12 @@ void CodeView::OnLostFocus(void) void CodeView::SetFontSize(int32_t size) { - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - m_OObjectText.SetSize(size); - #else - m_OObjectTextNormal.SetSize(size); - m_OObjectTextBold.SetSize(size); - m_OObjectTextItalic.SetSize(size); - m_OObjectTextBoldItalic.SetSize(size); - #endif + m_OObjectText.SetSize(size); SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ... } -#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - void CodeView::SetFontName(etk::UString fontName) - { - m_OObjectText.SetFont(fontName); - } -#else - void CodeView::SetFontNameNormal(etk::UString fontName) - { - m_OObjectTextNormal.SetFont(fontName); - } - - void CodeView::SetFontNameBold(etk::UString fontName) - { - m_OObjectTextBold.SetFont(fontName); - } - - void CodeView::SetFontNameItalic(etk::UString fontName) - { - m_OObjectTextItalic.SetFont(fontName); - } - - void CodeView::SetFontNameBoldItalic(etk::UString fontName) - { - m_OObjectTextBoldItalic.SetFont(fontName); - } -#endif +void CodeView::SetFontName(etk::UString fontName) +{ + m_OObjectText.SetFont(fontName); +} diff --git a/sources/appl/Gui/CodeView.h b/sources/appl/Gui/CodeView.h index eceb8ee..ca9b760 100644 --- a/sources/appl/Gui/CodeView.h +++ b/sources/appl/Gui/CodeView.h @@ -39,9 +39,7 @@ class CodeView :public ewol::WidgetScrooled { public: void Init(void); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - CodeView(etk::UString fontName, int32_t fontSize); - #endif + CodeView(etk::UString fontName, int32_t fontSize); CodeView(void); virtual ~CodeView(void); /** @@ -61,14 +59,7 @@ class CodeView :public ewol::WidgetScrooled etk::Vector > m_lineNumberList; void UpdateNumberOfLineReference(int32_t bufferID); // drawing elements : - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - ewol::TEXT_DISPLAY_TYPE m_OObjectText; - #else - ewol::TEXT_DISPLAY_TYPE m_OObjectTextNormal; - ewol::TEXT_DISPLAY_TYPE m_OObjectTextBold; - ewol::TEXT_DISPLAY_TYPE m_OObjectTextItalic; - ewol::TEXT_DISPLAY_TYPE m_OObjectTextBoldItalic; - #endif + ewol::TEXT_DISPLAY_TYPE m_OObjectText; ewol::OObject2DColored m_OObjectsColored; public: @@ -106,14 +97,7 @@ class CodeView :public ewol::WidgetScrooled virtual void OnLostFocus(void); public: void SetFontSize(int32_t size); - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - void SetFontName(etk::UString fontName); - #else - void SetFontNameNormal(etk::UString fontName); - void SetFontNameBold(etk::UString fontName); - void SetFontNameItalic(etk::UString fontName); - void SetFontNameBoldItalic(etk::UString fontName); - #endif + void SetFontName(etk::UString fontName); private: void CalculateMaxSize(void); protected: diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 698b59a..3646050 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -155,22 +155,11 @@ MainWindows::MainWindows(void) mySizerHori->SubWidgetAdd(mySizerVert2); // main buffer Area : - #ifdef APPL_BUFFER_FONT_DISTANCE_FIELD - myCodeView = new CodeView("Font/freefont/FreeMono.ttf", 24); - #else - myCodeView = new CodeView(); - #endif + myCodeView = new CodeView("FreeMono", 24); myCodeView->SetExpendX(true); myCodeView->SetExpendY(true); myCodeView->SetFillX(true); myCodeView->SetFillY(true); - #ifndef APPL_BUFFER_FONT_DISTANCE_FIELD - myCodeView->SetFontSize(11); - myCodeView->SetFontNameNormal( "Font/freefont/FreeMono.ttf"); - myCodeView->SetFontNameBold( "Font/freefont/FreeMonoBold.ttf"); - myCodeView->SetFontNameItalic( "Font/freefont/FreeMonoOblique.ttf"); - myCodeView->SetFontNameBoldItalic("Font/freefont/FreeMonoBoldOblique.ttf"); - #endif mySizerVert2->SubWidgetAdd(myCodeView); // search area : diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 208d4fc..dd330a2 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -67,8 +67,9 @@ void APP_Init(void) #endif ewol::ChangeSize(etk::Vector2D(800, 600)); etk::InitDefaultFolder(PROJECT_NAME); - - ewol::font::SetDefaultFont("Font/freefont/FreeSerif.ttf"); + + ewol::font::SetDefaultFont("FreeSerif"); + //ewol::font::SetDefaultFont("Font/freefont/FreeSerif.ttf"); //ewol::font::SetDefaultFont("Font/ACharmingFont.ttf"); #ifdef __TARGET_OS__Android ewol::font::SetDefaultSize(19);