diff options
Diffstat (limited to 'glcdgraphics/font.h')
-rw-r--r-- | glcdgraphics/font.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/glcdgraphics/font.h b/glcdgraphics/font.h index f3427d5..a77de14 100644 --- a/glcdgraphics/font.h +++ b/glcdgraphics/font.h @@ -9,7 +9,9 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2004 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> + * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * Andreas 'randy' Weinberger */ #ifndef _GLCDGRAPHICS_FONT_H_ @@ -28,12 +30,12 @@ class cBitmapCache; class cFont { public: - enum eLoadedFntType + enum eFontType { // native glcd font loaded - lftFNT, + ftFNT, // freetype2 font loaded - lftFT2 + ftFT2 }; private: int totalWidth; @@ -43,7 +45,10 @@ private: int lineHeight; cBitmap * characters[256]; - eLoadedFntType loadedFontType; + eFontType fontType; + + bool isutf8; + wchar_t iconv_lut[256]; // lookup table needed if encoding != UTF-8 cBitmapCache *characters_cache; void *ft2_library; //FT_Library @@ -55,7 +60,7 @@ public: cFont(); ~cFont(); - bool LoadFNT(const std::string & fileName); + bool LoadFNT(const std::string & fileName, const std::string & encoding = "UTF-8"); bool SaveFNT(const std::string & fileName) const; bool LoadFT2(const std::string & fileName, const std::string & encoding, int size, bool dingBats = false); @@ -71,20 +76,19 @@ public: void SetSpaceBetween(int width) { spaceBetween = width; }; void SetLineHeight(int height) { lineHeight = height; }; - int Width(int ch) const; + int Width(uint32_t ch) const; int Width(const std::string & str) const; int Width(const std::string & str, unsigned int len) const; - int Height(int ch) const; + int Height(uint32_t ch) const; int Height(const std::string & str) const; int Height(const std::string & str, unsigned int len) const; - const cBitmap * GetCharacter(int ch) const; + const cBitmap * GetCharacter(uint32_t ch) const; void SetCharacter(char ch, cBitmap * bitmapChar); void WrapText(int Width, int Height, std::string & Text, std::vector <std::string> & Lines, int * TextWidth = NULL) const; - - static void Utf8CodeAdjustCounter(const std::string & str, int & c, unsigned int & i); + bool IsUTF8(void) const { return isutf8; } }; } // end of namespace |