From e5afd58ab4d626baca3ae82e92a2db81fa91a2e4 Mon Sep 17 00:00:00 2001
From: Terraneo Federico <fede.tft@miosix.org>
Date: Mon, 5 Dec 2016 00:45:56 +0100
Subject: [PATCH] Factorized common code for setting and getting font and text
 color, and made overriding update() optional as it is not always needed

---
 display.cpp                          | 21 +++++++++++++++-
 display.h                            | 28 ++++++++++++++--------
 drivers/display_bitsboard.cpp        | 19 ++-------------
 drivers/display_bitsboard.h          | 35 ---------------------------
 drivers/display_mp3v2.cpp            | 19 ++-------------
 drivers/display_mp3v2.h              | 35 ---------------------------
 drivers/display_oledboard2.cpp       | 19 ++-------------
 drivers/display_oledboard2.h         | 35 ---------------------------
 drivers/display_qt.cpp               | 19 +++------------
 drivers/display_qt.h                 | 29 ----------------------
 drivers/display_redbull_v2.cpp       | 19 ++-------------
 drivers/display_redbull_v2.h         | 35 ---------------------------
 drivers/display_sony-newman.cpp      | 17 ++-----------
 drivers/display_sony-newman.h        | 32 +------------------------
 drivers/display_stm3210e-eval.cpp    | 20 ++--------------
 drivers/display_stm3210e-eval.h      | 36 ----------------------------
 drivers/display_stm32f4discovery.cpp | 19 ++-------------
 drivers/display_stm32f4discovery.h   | 35 ---------------------------
 drivers/display_strive.cpp           | 19 ++-------------
 drivers/display_strive.h             | 35 ---------------------------
 drivers/display_win.cpp              | 16 +------------
 drivers/display_win.h                | 29 ----------------------
 22 files changed, 59 insertions(+), 512 deletions(-)

diff --git a/display.cpp b/display.cpp
index f5dd8a7..936b3b4 100644
--- a/display.cpp
+++ b/display.cpp
@@ -26,12 +26,15 @@
  ***************************************************************************/
 
 #include "display.h"
+#include "misc_inst.h"
 #include "pthread_lock.h"
 
 #if MXGUI_SETTINGS_VERSION != 101
 #error Wrong mxgui_settings.h version. You need to upgrade it.
 #endif
 
+using namespace std;
+
 namespace mxgui {
 
 //
@@ -67,7 +70,7 @@ DisplayManager::DisplayManager()
 // class Display
 //
 
-Display::Display() : isDisplayOn(true)
+Display::Display() : isDisplayOn(true), font(miscFixed)
 {
     pthread_mutexattr_t temp;
     pthread_mutexattr_init(&temp);
@@ -98,6 +101,22 @@ void Display::setBrightness(int brt)
     doSetBrightness(brt);
 }
 
+void Display::setTextColor(pair<Color,Color> colors)
+{
+    Font::generatePalette(textColor,colors.first,colors.second);
+}
+
+pair<Color,Color> Display::getTextColor() const
+{
+    return make_pair(textColor[3],textColor[0]);
+}
+
+void Display::setFont(const Font& font) { this->font=font; }
+
+Font Display::getFont() const { return font; }
+
+void Display::update() {}
+
 Display::~Display() {}
 
 } //namespace mxgui
diff --git a/display.h b/display.h
index 3fc2ae1..f12d90f 100644
--- a/display.h
+++ b/display.h
@@ -163,10 +163,7 @@ public:
      */
     virtual ~Display();
 
-private:
-    Display(const Display&)=delete;
-    Display& operator=(const Display&)=delete;
-    
+protected:
     /**
      * Turn the display On after it has been turned Off.
      * Display initial state is On.
@@ -305,33 +302,44 @@ private:
      * Set colors used for writing text
      * \param colors a pair with the text foreground and background colors
      */
-    virtual void setTextColor(std::pair<Color,Color> colors)=0;
+    void setTextColor(std::pair<Color,Color> colors);
 
     /**
      * \return a pair with the foreground and background colors.
      * Those colors are used to draw text on screen
      */
-    virtual std::pair<Color,Color> getTextColor() const=0;
+    std::pair<Color,Color> getTextColor() const;
 
     /**
      * Set the font used for writing text
      * \param font new font
      */
-    virtual void setFont(const Font& font)=0;
+    void setFont(const Font& font);
 
     /**
      * \return the current font used to draw text
      */
-    virtual Font getFont() const=0;
+    Font getFont() const;
     
     /**
      * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
+     * visible. Backends that require it may override this.
      */
-    virtual void update()=0;
+    virtual void update();
 
+private:
+    Display(const Display&)=delete;
+    Display& operator=(const Display&)=delete;
+    
     pthread_mutex_t dispMutex; ///< To lock concurrent access to the display
     bool isDisplayOn;          ///< True if display is on
+    
+protected:
+    Font font;                 ///< Current font selected for writing text
+    /// textColors[0] is the background color, textColor[3] the foreground
+    /// while the other two are the intermediate colors for drawing antialiased
+    /// fonts. They remain just for compatibilty, as this screen in monochrome
+    Color textColor[4];
 
     friend class DrawingContext;
 };
diff --git a/drivers/display_bitsboard.cpp b/drivers/display_bitsboard.cpp
index 200891c..d424ceb 100644
--- a/drivers/display_bitsboard.cpp
+++ b/drivers/display_bitsboard.cpp
@@ -239,22 +239,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d)
 {
     bool fail=false;
@@ -280,8 +264,9 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(miscFixed), last()
+DisplayImpl::DisplayImpl(): buffer(0), last()
 {
+    setFont(miscFixed);
     setTextColor(make_pair(Color(black),Color(white)));
     {
         FastInterruptDisableLock dLock;
diff --git a/drivers/display_bitsboard.h b/drivers/display_bitsboard.h
index 168ff71..d3c0f96 100644
--- a/drivers/display_bitsboard.h
+++ b/drivers/display_bitsboard.h
@@ -195,36 +195,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-   /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
-
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
      * define a window on the display and write to its pixels.
@@ -419,11 +389,6 @@ private:
     #endif
 
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts. They remain just for compatibilty, as this screen in monochrome
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
     pixel_iterator last; ///< Last iterator for end of iteration check
     unsigned int *framebufferBitBandAlias; ///< For fast pixel_iterator
 };
diff --git a/drivers/display_mp3v2.cpp b/drivers/display_mp3v2.cpp
index 7d992eb..13f04df 100644
--- a/drivers/display_mp3v2.cpp
+++ b/drivers/display_mp3v2.cpp
@@ -256,22 +256,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2,
         IteratorDirection d)
 {
@@ -293,7 +277,7 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
+DisplayImpl::DisplayImpl(): buffer(0)
 {
     //FIXME: This assumes xram is already initialized an so D0..D15, A0, NOE,
     //NWE are correctly initialized
@@ -372,6 +356,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
     //Power up sequence -- end
     //
     
+    setFont(droid11);
     setTextColor(make_pair(Color(0xffff),Color(0x0000)));
     clear(black);
 }
diff --git a/drivers/display_mp3v2.h b/drivers/display_mp3v2.h
index 9bad9aa..2c29e0d 100644
--- a/drivers/display_mp3v2.h
+++ b/drivers/display_mp3v2.h
@@ -192,36 +192,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
-    
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
      * define a window on the display and write to its pixels.
@@ -519,11 +489,6 @@ private:
     }
     
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
 };
 
 } //namespace mxgui
diff --git a/drivers/display_oledboard2.cpp b/drivers/display_oledboard2.cpp
index 7acceab..10d82ba 100644
--- a/drivers/display_oledboard2.cpp
+++ b/drivers/display_oledboard2.cpp
@@ -289,22 +289,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2,
         IteratorDirection d)
 {
@@ -330,7 +314,7 @@ DisplayImpl::~DisplayImpl() {}
 
 DisplayImpl::DisplayImpl()
     : framebuffer1(reinterpret_cast<unsigned short*>(0xd0600000)),
-      buffer(framebuffer1+numPixels), font(droid21)
+      buffer(framebuffer1+numPixels)
 {
     /*
      * Display refresh rate is critical, as a high rate takes up a significant
@@ -499,6 +483,7 @@ DisplayImpl::DisplayImpl()
     sendCommand8(0x23,0x00);
     sendCommand8(0x26,0xa0);
     
+    setFont(droid21);
     setTextColor(make_pair(Color(0xffff),Color(0x0000)));
     clear(black);
     doTurnOn();
diff --git a/drivers/display_oledboard2.h b/drivers/display_oledboard2.h
index 941a73c..5e7eaa8 100644
--- a/drivers/display_oledboard2.h
+++ b/drivers/display_oledboard2.h
@@ -191,36 +191,6 @@ public:
      * \param c color of the line
      */
     void drawRectangle(Point a, Point b, Color c) override;
-
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
     
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
@@ -382,11 +352,6 @@ private:
      */
     Color * const framebuffer1;
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
     pixel_iterator last; ///< Last iterator for end of iteration check
     static const unsigned int bpp=sizeof(Color); ///< Bytes per pixel
     static const int numPixels=width*height; ///< Number of pixels of the display
diff --git a/drivers/display_qt.cpp b/drivers/display_qt.cpp
index f63235f..beac012 100644
--- a/drivers/display_qt.cpp
+++ b/drivers/display_qt.cpp
@@ -211,20 +211,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
 void DisplayImpl::update()
 {  
     backend.getSender()->update();
@@ -254,9 +240,10 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11), last(),
-        beginPixelCalled(false), backend(QTBackend::instance())
+DisplayImpl::DisplayImpl(): buffer(0), last(), beginPixelCalled(false),
+                            backend(QTBackend::instance())
 {
+    setFont(droid11);
     setTextColor(make_pair(Color(SIMULATOR_FGCOLOR),Color(SIMULATOR_BGCOLOR)));
 }
 
diff --git a/drivers/display_qt.h b/drivers/display_qt.h
index ceeba04..c679ecd 100644
--- a/drivers/display_qt.h
+++ b/drivers/display_qt.h
@@ -195,30 +195,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
     /**
      * Make all changes done to the display since the last call to update()
      * visible. This backends require it.
@@ -356,11 +332,6 @@ private:
     static const short int height=FrameBuffer::height;
 
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
     pixel_iterator last; ///< Last iterator for end of iteration check
     QTBackend& backend; ///< Backend which contains the framebuffer
     bool beginPixelCalled; ///< Used to check for beginPixel calls
diff --git a/drivers/display_redbull_v2.cpp b/drivers/display_redbull_v2.cpp
index 796c9ba..11cc0a2 100644
--- a/drivers/display_redbull_v2.cpp
+++ b/drivers/display_redbull_v2.cpp
@@ -188,22 +188,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2,
         IteratorDirection d)
 {
@@ -225,7 +209,7 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
+DisplayImpl::DisplayImpl(): buffer(0)
 {
     
     //LCD connection GPIO should have been initialized at
@@ -305,6 +289,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
     writeReg(0x004f,0);
     writeReg(0x004e,0);
     //Fill display
+    setFont(droid11);
     setTextColor(make_pair(white, black));
     clear(black);
 }
diff --git a/drivers/display_redbull_v2.h b/drivers/display_redbull_v2.h
index 45ec2af..cc7e2e1 100644
--- a/drivers/display_redbull_v2.h
+++ b/drivers/display_redbull_v2.h
@@ -198,36 +198,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
-
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
      * define a window on the display and write to its pixels.
@@ -439,11 +409,6 @@ private:
     }
 
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
 };
 
 } //namespace mxgui
diff --git a/drivers/display_sony-newman.cpp b/drivers/display_sony-newman.cpp
index e5247dc..8622ec3 100644
--- a/drivers/display_sony-newman.cpp
+++ b/drivers/display_sony-newman.cpp
@@ -346,20 +346,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
 void DisplayImpl::update() { waitDmaCompletion(); }
 
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1,
@@ -384,9 +370,10 @@ DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1,
 
 DisplayImpl::~DisplayImpl() {}
 
-DisplayImpl::DisplayImpl(): which(0), textColor(), font(droid11)
+DisplayImpl::DisplayImpl(): which(0)
 {
     doTurnOn();
+    setFont(droid11);
     setTextColor(make_pair(Color(0xffff),Color(0x0000)));
 }
 
diff --git a/drivers/display_sony-newman.h b/drivers/display_sony-newman.h
index c0f5aaa..79e5780 100644
--- a/drivers/display_sony-newman.h
+++ b/drivers/display_sony-newman.h
@@ -215,30 +215,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
     /**
      * Make all changes done to the display since the last call to update()
      * visible. This backends does require it.
@@ -357,8 +333,7 @@ private:
     
     /**
      * Constructor.
-     * Do not instantiate objects of this type directly from application code,
-     * use Display::instance() instead.
+     * Do not instantiate objects of this type directly from application code.
      */
     DisplayImpl();
 
@@ -484,11 +459,6 @@ private:
     Color pixel; ///< Buffer of one pixel, for overlapped I/O
     Color buffers[2][128]; ///< Line buffers for scanline overlapped I/O
     int which; ///< Currently empty buffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
 };
 
 } //namespace mxgui
diff --git a/drivers/display_stm3210e-eval.cpp b/drivers/display_stm3210e-eval.cpp
index 97e36a2..6e8341b 100644
--- a/drivers/display_stm3210e-eval.cpp
+++ b/drivers/display_stm3210e-eval.cpp
@@ -217,22 +217,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-std::pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1,
         Point p2, IteratorDirection d)
 {
@@ -254,8 +238,7 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN), textColor(),
-        font(droid11)
+DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN)
 {
     //FIXME: This assumes xram is already initialized an so D0..D15, A0, NOE,
     //NWE are correctly initialized
@@ -305,6 +288,7 @@ DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN), textColor(),
             break;
     }
 
+    setFont(droid11);
     setTextColor(make_pair(Color(0xffff),Color(0x0000)));
     clear(black);
 }
diff --git a/drivers/display_stm3210e-eval.h b/drivers/display_stm3210e-eval.h
index b0c974c..a0359fd 100644
--- a/drivers/display_stm3210e-eval.h
+++ b/drivers/display_stm3210e-eval.h
@@ -196,36 +196,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors);
-    
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
-
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
      * define a window on the display and write to its pixels.
@@ -534,12 +504,6 @@ private:
     
     Color *buffer; ///< For scanLineBuffer    
     DisplayType displayType;//Contains the display controller ID
-
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
 };
 
 } //namespace mxgui
diff --git a/drivers/display_stm32f4discovery.cpp b/drivers/display_stm32f4discovery.cpp
index efed3df..fe75d08 100644
--- a/drivers/display_stm32f4discovery.cpp
+++ b/drivers/display_stm32f4discovery.cpp
@@ -300,22 +300,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2,
         IteratorDirection d)
 {
@@ -341,7 +325,7 @@ DisplayImpl::~DisplayImpl() {}
 
 DisplayImpl::DisplayImpl()
     : framebuffer1(reinterpret_cast<unsigned short*>(0xd0600000)),
-      buffer(framebuffer1+numPixels), font(droid11)
+      buffer(framebuffer1+numPixels)
 {
     {
         FastInterruptDisableLock dLock;
@@ -483,6 +467,7 @@ DisplayImpl::DisplayImpl()
             | 0                //no dithering
             | LTDC_GCR_LTDCEN; //Display enabled
     
+    setFont(droid11);
     setTextColor(make_pair(Color(0xffff),Color(0x0000)));
     clear(black);
 }
diff --git a/drivers/display_stm32f4discovery.h b/drivers/display_stm32f4discovery.h
index 6b8bbe3..bee1d5b 100644
--- a/drivers/display_stm32f4discovery.h
+++ b/drivers/display_stm32f4discovery.h
@@ -191,36 +191,6 @@ public:
      * \param c color of the line
      */
     void drawRectangle(Point a, Point b, Color c) override;
-
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
     
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
@@ -382,11 +352,6 @@ private:
      */
     Color * const framebuffer1;
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
     pixel_iterator last; ///< Last iterator for end of iteration check
     static const unsigned int bpp=sizeof(Color); ///< Bytes per pixel
     static const int numPixels=width*height; ///< Number of pixels of the display
diff --git a/drivers/display_strive.cpp b/drivers/display_strive.cpp
index 0a9b397..0afac75 100644
--- a/drivers/display_strive.cpp
+++ b/drivers/display_strive.cpp
@@ -348,22 +348,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
-void DisplayImpl::update() {}
-
 DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2,
         IteratorDirection d)
 {
@@ -385,7 +369,7 @@ DisplayImpl::~DisplayImpl()
     if(buffer) delete[] buffer;
 }
 
-DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
+DisplayImpl::DisplayImpl(): buffer(0)
 {
     
     //LCD connection GPIO should have been initialized at
@@ -493,6 +477,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11)
     writeReg(0x07, D0 | D1 |DTE | GON | BASEE);
 
     //Fill display
+    setFont(droid11);
     setTextColor(make_pair(white, black));
     clear(black);
 }
diff --git a/drivers/display_strive.h b/drivers/display_strive.h
index 12164d7..741c3b2 100644
--- a/drivers/display_strive.h
+++ b/drivers/display_strive.h
@@ -191,36 +191,6 @@ public:
      * \param c color of the line
      */
     void drawRectangle(Point a, Point b, Color c) override;;
-
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
-    /**
-     * Make all changes done to the display since the last call to update()
-     * visible. This backends does not require it, so it is empty.
-     */
-    void update() override;
     
     /**
      * Pixel iterator. A pixel iterator is an output iterator that allows to
@@ -507,11 +477,6 @@ private:
     }
     
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
 };
 
 } //namespace mxgui
diff --git a/drivers/display_win.cpp b/drivers/display_win.cpp
index 58217c3..04b809e 100644
--- a/drivers/display_win.cpp
+++ b/drivers/display_win.cpp
@@ -214,20 +214,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c)
     line(Point(a.x(),b.y()),a,c);
 }
 
-void DisplayImpl::setTextColor(pair<Color,Color> colors)
-{
-    Font::generatePalette(textColor,colors.first,colors.second);
-}
-
-pair<Color,Color> DisplayImpl::getTextColor() const
-{
-    return make_pair(textColor[3],textColor[0]);
-}
-
-void DisplayImpl::setFont(const Font& font) { this->font=font; }
-
-Font DisplayImpl::getFont() const { return font; }
-
 void DisplayImpl::update()
 {
     beginPixelCalled=false;
@@ -258,11 +244,11 @@ DisplayImpl::~DisplayImpl()
 
 DisplayImpl::DisplayImpl():
         buffer(0),
-        font(droid11),
         last(),
         beginPixelCalled(false),
         backend(WinBackend::instance())
 {
+    setFont(droid11);
     setTextColor(make_pair(Color(0xffff), Color(0x0000)));
 }
 
diff --git a/drivers/display_win.h b/drivers/display_win.h
index 5c0d0dd..f35e5be 100644
--- a/drivers/display_win.h
+++ b/drivers/display_win.h
@@ -195,30 +195,6 @@ public:
      */
     void drawRectangle(Point a, Point b, Color c) override;
 
-    /**
-     * Set colors used for writing text
-     * \param fgcolor text color
-     * \param bgcolor background color
-     */
-    void setTextColor(std::pair<Color,Color> colors) override;
-
-    /**
-     * \return a pair with the foreground and background colors.
-     * Those colors are used to draw text on screen
-     */
-    std::pair<Color,Color> getTextColor() const override;
-
-    /**
-     * Set the font used for writing text
-     * \param font new font
-     */
-    void setFont(const Font& font) override;
-
-    /**
-     * \return the current font used to draw text
-     */
-    Font getFont() const override;
-
     /**
      * Make all changes done to the display since the last call to update()
      * visible. This backends require it.
@@ -356,11 +332,6 @@ private:
     static const short int height = SIMULATOR_DISP_HEIGHT;
 
     Color *buffer; ///< For scanLineBuffer
-    /// textColors[0] is the background color, textColor[3] the foreground
-    /// while the other two are the intermediate colors for drawing antialiased
-    /// fonts.
-    Color textColor[4];
-    Font font; ///< Current font selected for writing text
     pixel_iterator last; ///< Last iterator for end of iteration check
     WinBackend& backend; ///< Backend which contains the framebuffer
     bool beginPixelCalled; ///< Used to check for beginPixel calls
-- 
GitLab