graphlcd-base/glcdgraphics/font.h
author root@rika
Wed, 06 Feb 2008 17:32:55 +0000
changeset 4 df6a40031aa5
permissions -rw-r--r--
added graphlcd-base
root@4
     1
/*
root@4
     2
 * GraphLCD graphics library
root@4
     3
 *
root@4
     4
 * font.h  -  font handling
root@4
     5
 *
root@4
     6
 * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
root@4
     7
 *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
root@4
     8
 *
root@4
     9
 * This file is released under the GNU General Public License. Refer
root@4
    10
 * to the COPYING file distributed with this package.
root@4
    11
 *
root@4
    12
 * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
root@4
    13
 */
root@4
    14
root@4
    15
#ifndef _GLCDGRAPHICS_FONT_H_
root@4
    16
#define _GLCDGRAPHICS_FONT_H_
root@4
    17
root@4
    18
#include <string>
root@4
    19
#include <vector>
root@4
    20
root@4
    21
#include "bitmap.h"
root@4
    22
root@4
    23
namespace GLCD
root@4
    24
{
root@4
    25
root@4
    26
class cFont
root@4
    27
{
root@4
    28
private:
root@4
    29
    int totalWidth;
root@4
    30
    int totalHeight;
root@4
    31
    int totalAscent;
root@4
    32
    int spaceBetween;
root@4
    33
    int lineHeight;
root@4
    34
root@4
    35
    cBitmap * characters[256];
root@4
    36
protected:
root@4
    37
    void Init();
root@4
    38
    void Unload();
root@4
    39
public:
root@4
    40
    cFont();
root@4
    41
    ~cFont();
root@4
    42
root@4
    43
    bool LoadFNT(const std::string & fileName);
root@4
    44
    bool SaveFNT(const std::string & fileName) const;
root@4
    45
    bool LoadFT2(const std::string & fileName, const std::string & encoding,
root@4
    46
                 int size, bool dingBats = false);
root@4
    47
    int TotalWidth() const { return totalWidth; };
root@4
    48
    int TotalHeight() const { return totalHeight; };
root@4
    49
    int TotalAscent() const { return totalAscent; };
root@4
    50
    int SpaceBetween() const { return spaceBetween; };
root@4
    51
    int LineHeight() const { return lineHeight; };
root@4
    52
root@4
    53
    void SetTotalWidth(int width) { totalWidth = width; };
root@4
    54
    void SetTotalHeight(int height) { totalHeight = height; };
root@4
    55
    void SetTotalAscent(int ascent) { totalAscent = ascent; };
root@4
    56
    void SetSpaceBetween(int width) { spaceBetween = width; };
root@4
    57
    void SetLineHeight(int height) { lineHeight = height; };
root@4
    58
root@4
    59
    int Width(char ch) const;
root@4
    60
    int Width(const std::string & str) const;
root@4
    61
    int Width(const std::string & str, unsigned int len) const;
root@4
    62
    int Height(char ch) const;
root@4
    63
    int Height(const std::string & str) const;
root@4
    64
    int Height(const std::string & str, unsigned int len) const;
root@4
    65
root@4
    66
    const cBitmap * GetCharacter(char ch) const;
root@4
    67
    void SetCharacter(char ch, cBitmap * bitmapChar);
root@4
    68
root@4
    69
    void WrapText(int Width, int Height, std::string & Text,
root@4
    70
                  std::vector <std::string> & Lines, int * TextWidth = NULL) const;
root@4
    71
};
root@4
    72
root@4
    73
} // end of namespace
root@4
    74
root@4
    75
#endif