vdr 2.7.7
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 4.3 2017/11/11 14:05:07 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
24 fontSml
25#define eDvbFontSize (fontSml + 1)
26 };
27
28class cBitmap;
29class cPixmap;
30typedef uint32_t tColor; // see also osd.h
31typedef uint8_t tIndex;
32
33extern const char *DefaultFontOsd;
34extern const char *DefaultFontSml;
35extern const char *DefaultFontFix;
36
37class cFont {
38private:
39 static cFont *fonts[];
40public:
41 virtual ~cFont() {}
42 virtual const char *FontName(void) const { return ""; }
44 virtual int Size(void) const { return Height(); }
48 virtual int Width(void) const = 0;
51 virtual int Width(uint c) const = 0;
53 virtual int Width(const char *s) const = 0;
55 virtual int Height(void) const = 0;
59 int Height(const char *s) const { return Height(); }
61 virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const = 0;
64 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
67 static void SetFont(eDvbFont Font, const char *Name, int CharHeight);
70 static const cFont *GetFont(eDvbFont Font);
78 static cFont *CreateFont(const char *Name, int CharHeight, int CharWidth = 0);
88 static bool GetAvailableFontNames(cStringList *FontNames, bool Monospaced = false);
95 static cString GetFontFileName(const char *FontName);
97#ifdef BIDI
98 static cString Bidi(const char *Ltr);
101#endif
102 };
103
105private:
106 char *text;
107 char *eol;
108 int lines;
110public:
111 cTextWrapper(void);
112 cTextWrapper(const char *Text, const cFont *Font, int Width);
114 void Set(const char *Text, const cFont *Font, int Width);
119 const char *Text(void);
121 int Lines(void) { return lines; }
123 const char *GetLine(int Line);
125 };
126
127#endif //__FONT_H
Definition osd.h:169
Definition font.h:37
virtual int Width(const char *s) const =0
Returns the width of the given string in pixel.
virtual int Width(void) const =0
Returns the original character width as requested when the font was created, or 0 if the default widt...
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:429
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
virtual int Size(void) const
Returns the original size as requested when the font was created.
Definition font.h:44
static cFont * fonts[]
Definition font.h:404
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.
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:406
virtual ~cFont()
Definition font.h:41
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:440
int Height(const char *s) const
Returns the height of this font in pixel (obsolete, just for backwards compatibility).
Definition font.h:59
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
static const cFont * GetFont(eDvbFont Font)
Gets the given Font, which was previously set by a call to SetFont().
Definition font.c:412
virtual const char * FontName(void) const
Returns the font name.
Definition font.h:42
virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
Definition font.h:64
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
Definition font.c:482
Definition osd.h:459
char * text
Definition font.h:106
const char * GetLine(int Line)
Returns the given Line. The first line is numbered 0.
Definition font.c:638
char * eol
Definition font.h:107
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 ...
Definition font.c:566
cTextWrapper(void)
Definition font.c:548
int lastLine
Definition font.h:109
int lines
Definition font.h:108
const char * Text(void)
Returns the full wrapped text.
Definition font.c:629
~cTextWrapper()
Definition font.c:561
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
Definition font.h:121
const char * DefaultFontOsd
Definition font.c:24
const char * DefaultFontSml
Definition font.c:25
const char * DefaultFontFix
Definition font.c:26
eDvbFont
Definition font.h:21
@ fontOsd
Definition font.h:22
@ fontFix
Definition font.h:23
uint32_t tColor
Definition font.h:30
uint8_t tIndex
Definition font.h:31
static const cCursesFont Font
Definition skincurses.c:31