diff options
Diffstat (limited to 'font.h')
-rw-r--r-- | font.h | 64 |
1 files changed, 27 insertions, 37 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: font.h 1.15 2007/03/11 09:50:42 kls Exp $ + * $Id: font.h 1.16 2007/06/10 12:58:54 kls Exp $ */ #ifndef __FONT_H @@ -13,6 +13,10 @@ #include <stdint.h> #include <stdlib.h> +#define MAXFONTNAME 64 +#define MAXFONTSIZE 64 +#define FONTDIR "/usr/share/fonts/truetype" + enum eDvbFont { fontOsd, fontFix, @@ -20,49 +24,35 @@ enum eDvbFont { #define eDvbFontSize (fontSml + 1) }; -enum eDvbCode { - code_iso8859_1, - code_iso8859_2, - code_iso8859_5, - code_iso8859_7, - code_iso8859_9, - code_iso8859_13, - code_iso8859_15, -#define eDvbCodeSize (code_iso8859_15 + 1) - }; +class cBitmap; +typedef uint32_t tColor; // see also osd.h +typedef uint8_t tIndex; 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); + virtual int Width(uint c) const = 0; + ///< Returns the width of the given character in pixel. + virtual int Width(const char *s) const = 0; + ///< Returns the width of the given string in pixel. + virtual int Height(void) const = 0; + ///< Returns the height of this font in pixel (all characters have the same height). + int Height(const char *s) const { return Height(); } + ///< Returns the height of this font in pixel (obsolete, just for backwards compatibilty). + virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const = 0; + ///< Draws the given text into the Bitmap at position (x, y) with the given colors. + ///< The text will not exceed the given Width (if > 0), and will end with a complete character. + static void SetFont(eDvbFont Font, const char *Name, int CharHeight); + ///< Sets the given Font to use the font data from the file Name and make its characters + ///< CharHeight pixels high. static const cFont *GetFont(eDvbFont Font); + ///< Gets the given Font, which was previously set by a call to SetFont(). + ///< If no SetFont() call has been made, the font as defined in the setup is returned. + ///< The caller must not use the returned font outside the scope in which + ///< it was retrieved by the call to GetFont(), because a call to SetFont() + ///< may delete an existing font. }; class cTextWrapper { |