1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/graphlcd-base/glcdgraphics/font.h Wed Feb 06 17:32:55 2008 +0000
1.3 @@ -0,0 +1,75 @@
1.4 +/*
1.5 + * GraphLCD graphics library
1.6 + *
1.7 + * font.h - font handling
1.8 + *
1.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
1.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
1.11 + *
1.12 + * This file is released under the GNU General Public License. Refer
1.13 + * to the COPYING file distributed with this package.
1.14 + *
1.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
1.16 + */
1.17 +
1.18 +#ifndef _GLCDGRAPHICS_FONT_H_
1.19 +#define _GLCDGRAPHICS_FONT_H_
1.20 +
1.21 +#include <string>
1.22 +#include <vector>
1.23 +
1.24 +#include "bitmap.h"
1.25 +
1.26 +namespace GLCD
1.27 +{
1.28 +
1.29 +class cFont
1.30 +{
1.31 +private:
1.32 + int totalWidth;
1.33 + int totalHeight;
1.34 + int totalAscent;
1.35 + int spaceBetween;
1.36 + int lineHeight;
1.37 +
1.38 + cBitmap * characters[256];
1.39 +protected:
1.40 + void Init();
1.41 + void Unload();
1.42 +public:
1.43 + cFont();
1.44 + ~cFont();
1.45 +
1.46 + bool LoadFNT(const std::string & fileName);
1.47 + bool SaveFNT(const std::string & fileName) const;
1.48 + bool LoadFT2(const std::string & fileName, const std::string & encoding,
1.49 + int size, bool dingBats = false);
1.50 + int TotalWidth() const { return totalWidth; };
1.51 + int TotalHeight() const { return totalHeight; };
1.52 + int TotalAscent() const { return totalAscent; };
1.53 + int SpaceBetween() const { return spaceBetween; };
1.54 + int LineHeight() const { return lineHeight; };
1.55 +
1.56 + void SetTotalWidth(int width) { totalWidth = width; };
1.57 + void SetTotalHeight(int height) { totalHeight = height; };
1.58 + void SetTotalAscent(int ascent) { totalAscent = ascent; };
1.59 + void SetSpaceBetween(int width) { spaceBetween = width; };
1.60 + void SetLineHeight(int height) { lineHeight = height; };
1.61 +
1.62 + int Width(char ch) const;
1.63 + int Width(const std::string & str) const;
1.64 + int Width(const std::string & str, unsigned int len) const;
1.65 + int Height(char ch) const;
1.66 + int Height(const std::string & str) const;
1.67 + int Height(const std::string & str, unsigned int len) const;
1.68 +
1.69 + const cBitmap * GetCharacter(char ch) const;
1.70 + void SetCharacter(char ch, cBitmap * bitmapChar);
1.71 +
1.72 + void WrapText(int Width, int Height, std::string & Text,
1.73 + std::vector <std::string> & Lines, int * TextWidth = NULL) const;
1.74 +};
1.75 +
1.76 +} // end of namespace
1.77 +
1.78 +#endif