mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Using dummy font if no fonts are installed
This commit is contained in:
parent
79b1c68ffb
commit
3c68ef28d0
2
HISTORY
2
HISTORY
@ -5244,3 +5244,5 @@ Video Disk Recorder Revision History
|
||||
- Replaced strn0cpy() with Utf8Strn0Cpy() where necessary.
|
||||
- Now using 'fontconfig' to determine which fonts to use (thanks to Anssi Hannula
|
||||
for code and hints on how to do this).
|
||||
- If no fonts are installed, VDR now uses a dummy font that doesn't actually draw
|
||||
any text, and logs an error message.
|
||||
|
23
font.c
23
font.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* how to reach the author.
|
||||
*
|
||||
* $Id: font.c 1.16 2007/06/17 11:03:33 kls Exp $
|
||||
* $Id: font.c 1.17 2007/06/17 11:46:25 kls Exp $
|
||||
*/
|
||||
|
||||
#include "font.h"
|
||||
@ -287,14 +287,33 @@ void cFreetypeFont::DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColo
|
||||
}
|
||||
}
|
||||
|
||||
// --- cDummyFont ------------------------------------------------------------
|
||||
|
||||
// A dummy font, in case there are no fonts installed:
|
||||
|
||||
class cDummyFont : public cFont {
|
||||
public:
|
||||
virtual int Width(uint c) const { return 10; }
|
||||
virtual int Width(const char *s) const { return 50; }
|
||||
virtual int Height(void) const { return 20; }
|
||||
virtual void DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const {}
|
||||
};
|
||||
|
||||
// --- cFont -----------------------------------------------------------------
|
||||
|
||||
cFont *cFont::fonts[eDvbFontSize] = { NULL };
|
||||
|
||||
void cFont::SetFont(eDvbFont Font, const char *Name, int CharHeight)
|
||||
{
|
||||
cString fn = GetFontFileName(Name);
|
||||
if (*fn) {
|
||||
delete fonts[Font];
|
||||
fonts[Font] = new cFreetypeFont(GetFontFileName(Name), CharHeight);
|
||||
fonts[Font] = new cFreetypeFont(fn, CharHeight);
|
||||
}
|
||||
if (!fonts[Font] || !fonts[Font]->Height()) {
|
||||
delete fonts[Font];
|
||||
fonts[Font] = new cDummyFont;
|
||||
}
|
||||
}
|
||||
|
||||
const cFont *cFont::GetFont(eDvbFont Font)
|
||||
|
8
vdr.c
8
vdr.c
@ -22,7 +22,7 @@
|
||||
*
|
||||
* The project's page is at http://www.cadsoft.de/vdr
|
||||
*
|
||||
* $Id: vdr.c 1.292 2007/06/15 13:20:34 kls Exp $
|
||||
* $Id: vdr.c 1.293 2007/06/17 11:23:08 kls Exp $
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
@ -550,6 +550,12 @@ int main(int argc, char *argv[])
|
||||
))
|
||||
EXIT(2);
|
||||
|
||||
if (!*cFont::GetFontFileName(Setup.FontOsd)) {
|
||||
const char *msg = "no fonts available - OSD will not show any text!";
|
||||
fprintf(stderr, "vdr: %s\n", msg);
|
||||
esyslog("ERROR: %s", msg);
|
||||
}
|
||||
|
||||
// Recordings:
|
||||
|
||||
Recordings.Update();
|
||||
|
Loading…
Reference in New Issue
Block a user