vdr  2.2.0
font.h
Go to the documentation of this file.
1 /*
2  * font.h: Font handling for the DVB On Screen Display
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: font.h 3.1 2014/01/07 12:11:55 kls Exp $
8  */
9 
10 #ifndef __FONT_H
11 #define __FONT_H
12 
13 #include <stdint.h>
14 #include <stdlib.h>
15 #include "tools.h"
16 
17 #define MAXFONTNAME 64
18 #define MINFONTSIZE 10
19 #define MAXFONTSIZE 64
20 
21 enum eDvbFont {
24  fontSml
25 #define eDvbFontSize (fontSml + 1)
26  };
27 
28 class cBitmap;
29 class cPixmap;
30 typedef uint32_t tColor; // see also osd.h
31 typedef uint8_t tIndex;
32 
33 extern const char *DefaultFontOsd;
34 extern const char *DefaultFontSml;
35 extern const char *DefaultFontFix;
36 
37 class cFont {
38 private:
39  static cFont *fonts[];
40 public:
41  virtual ~cFont() {}
42  virtual const char *FontName(void) const { return ""; }
44  virtual int Size(void) const { return Height(); }
47  virtual int Width(uint c) const = 0;
49  virtual int Width(const char *s) const = 0;
51  virtual int Height(void) const = 0;
53  int Height(const char *s) const { return Height(); }
55  virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const = 0;
58  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
61  static void SetFont(eDvbFont Font, const char *Name, int CharHeight);
64  static const cFont *GetFont(eDvbFont Font);
72  static cFont *CreateFont(const char *Name, int CharHeight, int CharWidth = 0);
80  static bool GetAvailableFontNames(cStringList *FontNames, bool Monospaced = false);
87  static cString GetFontFileName(const char *FontName);
89 #ifdef BIDI
90  static cString Bidi(const char *Ltr);
93 #endif
94  };
95 
96 class cTextWrapper {
97 private:
98  char *text;
99  char *eol;
100  int lines;
101  int lastLine;
102 public:
103  cTextWrapper(void);
104  cTextWrapper(const char *Text, const cFont *Font, int Width);
105  ~cTextWrapper();
106  void Set(const char *Text, const cFont *Font, int Width);
111  const char *Text(void);
113  int Lines(void) { return lines; }
115  const char *GetLine(int Line);
117  };
118 
119 #endif //__FONT_H
char * text
Definition: font.h:98
Definition: osd.h:454
const char * DefaultFontSml
Definition: font.c:25
Definition: font.h:23
virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
Definition: font.h:58
int lines
Definition: font.h:100
static void SetFont(eDvbFont Font, const char *Name, int CharHeight)
< Draws the given text into the Pixmap at position (x, y) with the given colors.
Definition: font.c:400
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
Definition: font.h:113
static cFont * fonts[]
Definition: font.h:39
const char * DefaultFontOsd
Definition: font.c:24
Definition: osd.h:169
eDvbFont
Definition: font.h:21
Definition: font.h:22
virtual const char * FontName(void) const
Returns the font name.
Definition: font.h:42
char * eol
Definition: font.h:99
static const cCursesFont Font
Definition: skincurses.c:30
int lastLine
Definition: font.h:101
static cFont * CreateFont(const char *Name, int CharHeight, int CharWidth=0)
Creates a new font object with the given Name and makes its characters CharHeight pixels high...
Definition: font.c:423
const char * DefaultFontFix
Definition: font.c:26
virtual int Size(void) const
Returns the original size as requested when the font was created.
Definition: font.h:44
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
Definition: font.c:474
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
static bool GetAvailableFontNames(cStringList *FontNames, bool Monospaced=false)
Queries the font configuration for a list of available font names, which is returned in FontNames...
Definition: font.c:432
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
virtual ~cFont()
Definition: font.h:41
uint8_t tIndex
Definition: font.h:31
int Height(const char *s) const
Returns the height of this font in pixel (obsolete, just for backwards compatibility).
Definition: font.h:53
Definition: font.h:37
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.
Definition: tools.h:168
static const cFont * GetFont(eDvbFont Font)
Gets the given Font, which was previously set by a call to SetFont().
Definition: font.c:406
uint32_t tColor
Definition: font.h:29