2000-10-03 10:34:48 +02:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2005-01-14 13:30:57 +01:00
|
|
|
* $Id: font.h 1.10 2005/01/14 13:25:35 kls Exp $
|
2000-10-03 10:34:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FONT_H
|
|
|
|
#define __FONT_H
|
|
|
|
|
2003-10-24 12:53:12 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2000-10-03 10:34:48 +02:00
|
|
|
enum eDvbFont {
|
|
|
|
fontOsd,
|
2000-11-18 15:46:00 +01:00
|
|
|
fontFix,
|
2003-10-24 12:53:12 +02:00
|
|
|
fontSml
|
|
|
|
#define eDvbFontSize (fontSml + 1)
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eDvbCode {
|
|
|
|
code_iso8859_1,
|
2004-05-16 12:05:40 +02:00
|
|
|
code_iso8859_2,
|
2004-01-16 13:34:43 +01:00
|
|
|
code_iso8859_5,
|
|
|
|
code_iso8859_7,
|
2005-01-14 13:30:57 +01:00
|
|
|
code_iso8859_13,
|
2004-10-23 14:07:41 +02:00
|
|
|
code_iso8859_15,
|
|
|
|
#define eDvbCodeSize (code_iso8859_15 + 1)
|
2000-10-03 10:34:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class cFont {
|
|
|
|
public:
|
|
|
|
enum { NUMCHARS = 256 };
|
|
|
|
typedef unsigned long tPixelData;
|
|
|
|
struct tCharData {
|
|
|
|
tPixelData width, height;
|
|
|
|
tPixelData lines[1];
|
|
|
|
};
|
|
|
|
private:
|
2003-10-24 12:53:12 +02:00
|
|
|
static eDvbCode code;
|
|
|
|
static cFont *fonts[];
|
2000-10-03 10:34:48 +02:00
|
|
|
const tCharData *data[NUMCHARS];
|
2004-05-16 10:35:36 +02:00
|
|
|
int height;
|
2000-10-03 10:34:48 +02:00
|
|
|
public:
|
2003-10-24 12:53:12 +02:00
|
|
|
cFont(void *Data);
|
|
|
|
void SetData(void *Data);
|
2004-05-31 14:09:52 +02:00
|
|
|
virtual int Width(unsigned char c) const { return data[c]->width; }
|
2004-05-16 10:35:36 +02:00
|
|
|
///< Returns the width of the given character.
|
2004-05-31 14:09:52 +02:00
|
|
|
virtual int Width(const char *s) const;
|
2004-05-16 10:35:36 +02:00
|
|
|
///< Returns the width of the given string.
|
2004-05-31 14:09:52 +02:00
|
|
|
virtual int Height(unsigned char c) const { return data[c]->height; }
|
2004-05-16 10:35:36 +02:00
|
|
|
///< Returns the height of the given character.
|
2004-05-31 14:09:52 +02:00
|
|
|
virtual int Height(const char *s) const;
|
2004-05-16 10:35:36 +02:00
|
|
|
///< Returns the height of the given string.
|
2004-05-31 14:09:52 +02:00
|
|
|
virtual int Height(void) const { return height; }
|
2004-05-16 10:35:36 +02:00
|
|
|
///< Returns the height of this font (all characters have the same height).
|
2003-10-24 12:53:12 +02:00
|
|
|
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, void *Data = NULL);
|
|
|
|
static const cFont *GetFont(eDvbFont Font);
|
2000-10-03 10:34:48 +02:00
|
|
|
};
|
|
|
|
|
2004-05-16 10:35:36 +02:00
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
2000-10-03 10:34:48 +02:00
|
|
|
#endif //__FONT_H
|