vdr  1.7.27
font.h
Go to the documentation of this file.
00001 /*
00002  * font.h: Font handling for the DVB On Screen Display
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: font.h 2.6 2011/12/04 13:38:17 kls Exp $
00008  */
00009 
00010 #ifndef __FONT_H
00011 #define __FONT_H
00012 
00013 #include <stdint.h>
00014 #include <stdlib.h>
00015 #include "tools.h"
00016 
00017 #define MAXFONTNAME 64
00018 #define MINFONTSIZE 10
00019 #define MAXFONTSIZE 64
00020 
00021 enum eDvbFont {
00022   fontOsd,
00023   fontFix,
00024   fontSml
00025 #define eDvbFontSize (fontSml + 1)
00026   };
00027 
00028 class cBitmap;
00029 class cPixmap;
00030 typedef uint32_t tColor; // see also osd.h
00031 typedef uint8_t tIndex;
00032 
00033 extern const char *DefaultFontOsd;
00034 extern const char *DefaultFontSml;
00035 extern const char *DefaultFontFix;
00036 
00037 class cFont {
00038 private:
00039   static cFont *fonts[];
00040 public:
00041   virtual ~cFont() {}
00042   virtual const char *FontName(void) const { return ""; }
00044   virtual int Size(void) const { return Height(); }
00047   virtual int Width(uint c) const = 0;
00049   virtual int Width(const char *s) const = 0;
00051   virtual int Height(void) const = 0;
00053   int Height(const char *s) const { return Height(); }
00055   virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const = 0;
00058   virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}; // not "pure", so that existing implementations still compile
00061   static void SetFont(eDvbFont Font, const char *Name, int CharHeight);
00064   static const cFont *GetFont(eDvbFont Font);
00072   static cFont *CreateFont(const char *Name, int CharHeight, int CharWidth = 0);
00080   static bool GetAvailableFontNames(cStringList *FontNames, bool Monospaced = false);
00087   static cString GetFontFileName(const char *FontName);
00089 #ifdef BIDI
00090   static cString Bidi(const char *Ltr);
00093 #endif
00094   };
00095 
00096 class cTextWrapper {
00097 private:
00098   char *text;
00099   char *eol;
00100   int lines;
00101   int lastLine;
00102 public:
00103   cTextWrapper(void);
00104   cTextWrapper(const char *Text, const cFont *Font, int Width);
00105   ~cTextWrapper();
00106   void Set(const char *Text, const cFont *Font, int Width);
00111   const char *Text(void);
00113   int Lines(void) { return lines; }
00115   const char *GetLine(int Line);
00117   };
00118 
00119 #endif //__FONT_H