1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* font.h: Font handling for the DVB On Screen Display
*
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: font.h 1.14 2006/12/03 16:42:10 kls Exp $
*/
#ifndef __FONT_H
#define __FONT_H
#include <stdint.h>
#include <stdlib.h>
enum eDvbFont {
fontOsd,
fontFix,
fontSml
#define eDvbFontSize (fontSml + 1)
};
enum eDvbCode {
code_iso8859_1,
code_iso8859_2,
code_iso8859_5,
code_iso8859_7,
code_iso8859_13,
code_iso8859_15,
#define eDvbCodeSize (code_iso8859_15 + 1)
};
class cFont {
public:
enum { NUMCHARS = 256 };
typedef uint32_t tPixelData;
struct tCharData {
tPixelData width, height;
tPixelData lines[1];
};
private:
static eDvbCode code;
static cFont *fonts[];
const tCharData *data[NUMCHARS];
int height;
public:
cFont(const void *Data);
virtual ~cFont() {}
void SetData(const void *Data);
virtual int Width(unsigned char c) const { return data[c]->width; }
///< Returns the width of the given character.
virtual int Width(const char *s) const;
///< Returns the width of the given string.
virtual int Height(unsigned char c) const { return data[c]->height; }
///< Returns the height of the given character.
virtual int Height(const char *s) const;
///< Returns the height of the given string.
virtual int Height(void) const { return height; }
///< Returns the height of this font (all characters have the same height).
const tCharData *CharData(unsigned char c) const { return data[c]; }
static bool SetCode(const char *Code);
static void SetCode(eDvbCode Code);
static void SetFont(eDvbFont Font, const void *Data = NULL);
static const cFont *GetFont(eDvbFont Font);
};
class cTextWrapper {
private:
char *text;
char *eol;
int lines;
int lastLine;
public:
cTextWrapper(void);
cTextWrapper(const char *Text, const cFont *Font, int Width);
~cTextWrapper();
void Set(const char *Text, const cFont *Font, int Width);
///< Wraps the Text to make it fit into the area defined by the given Width
///< when displayed with the given Font.
///< Wrapping is done by inserting the necessary number of newline
///< characters into the string.
const char *Text(void);
///< Returns the full wrapped text.
int Lines(void) { return lines; }
///< Returns the actual number of lines needed to display the full wrapped text.
const char *GetLine(int Line);
///< Returns the given Line. The first line is numbered 0.
};
#endif //__FONT_H
|