vdr 2.6.1
include/vdr/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
104class cTextWrapper {
105private:
106 char *text;
107 char *eol;
108 int lines;
109 int lastLine;
110public:
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: 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 bool GetAvailableFontNames(cStringList *FontNames, bool Monospaced=false)
Queries the font configuration for a list of available font names, which is returned in FontNames.
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.
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.
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.
virtual ~cFont()
int Height(const char *s) const
Returns the height of this font in pixel (obsolete, just for backwards compatibility).
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
virtual const char * FontName(void) const
Returns the font name.
static cString GetFontFileName(const char *FontName)
Returns the actual font file name for the given FontName.
static const cFont * GetFont(eDvbFont Font)
Gets the given Font, which was previously set by a call to SetFont().
static cFont * fonts[]
Definition: font.h:39
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.
virtual void DrawText(cPixmap *Pixmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
cTextWrapper(const char *Text, const cFont *Font, int Width)
const char * GetLine(int Line)
Returns the given Line. The first line is numbered 0.
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 ...
cTextWrapper(void)
char * text
Definition: font.h:106
int lastLine
Definition: font.h:109
int lines
Definition: font.h:108
const char * Text(void)
Returns the full wrapped text.
Definition: font.c:628
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
eDvbFont
Definition: font.h:21
uint32_t tColor
Definition: font.h:30
const char * DefaultFontOsd
Definition: font.c:24
@ fontOsd
@ fontFix
const char * DefaultFontSml
Definition: font.c:25
const char * DefaultFontFix
Definition: font.c:26
uint32_t tColor
uint8_t tIndex
static const cCursesFont Font
Definition: skincurses.c:31