diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2003-10-24 12:53:12 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2003-10-24 12:53:12 +0200 |
commit | c94570e69dfca940ba04829debb93e421f77c4f0 (patch) | |
tree | 26488bf901cb4e7a2b30db914086cb0f45dd2349 /font.c | |
parent | 2b29a5ce367d464fd10d6014990c881eccf5207e (diff) | |
download | vdr-c94570e69dfca940ba04829debb93e421f77c4f0.tar.gz vdr-c94570e69dfca940ba04829debb93e421f77c4f0.tar.bz2 |
Changed font handling to allow language specific character sets; adopted the small font character set from the "Elchi" patch
Diffstat (limited to 'font.c')
-rw-r--r-- | font.c | 72 |
1 files changed, 57 insertions, 15 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: font.c 1.2 2000/11/18 15:16:08 kls Exp $ + * $Id: font.c 1.3 2003/10/24 12:51:43 kls Exp $ */ #include "font.h" @@ -12,24 +12,32 @@ #include "fontfix.c" #include "fontosd.c" +#include "fontsml.c" -cFont::cFont(eDvbFont Font) -{ +static void *FontData[eDvbCodeSize][eDvbFontSize] = { + { FontOsd_iso8859_1, FontFix_iso8859_1, FontSml_iso8859_1 }, + }; + +static const char *FontCode[eDvbCodeSize] = { + "iso8859-1", + }; -#define FONTINDEX(Name)\ - case font##Name: for (int i = 0; i < NUMCHARS; i++)\ - data[i] = (tCharData *)&Font##Name[i < 32 ? 0 : i - 32];\ - break; +eDvbCode cFont::code = code_iso8859_1; +cFont *cFont::fonts[eDvbFontSize] = { NULL }; - switch (Font) { - default: - FONTINDEX(Osd); - FONTINDEX(Fix); - // TODO others... - } +cFont::cFont(void *Data) +{ + SetData(Data); } -int cFont::Width(const char *s) +void cFont::SetData(void *Data) +{ + int h = ((tCharData *)Data)->height; + for (int i = 0; i < NUMCHARS; i++) + data[i] = (tCharData *)&((tPixelData *)Data)[(i < 32 ? 0 : i - 32) * (h + 2)]; +} + +int cFont::Width(const char *s) const { int w = 0; while (s && *s) @@ -37,7 +45,7 @@ int cFont::Width(const char *s) return w; } -int cFont::Height(const char *s) +int cFont::Height(const char *s) const { int h = 0; if (s && *s) @@ -45,3 +53,37 @@ int cFont::Height(const char *s) return h; } +bool cFont::SetCode(const char *Code) +{ + for (int i = 0; i < eDvbCodeSize; i++) { + if (strcmp(Code, FontCode[i]) == 0) { + SetCode(eDvbCode(i)); + return true; + } + } + return false; +} + +void cFont::SetCode(eDvbCode Code) +{ + if (code != Code) { + code = Code; + for (int i = 0; i < eDvbFontSize; i++) { + if (fonts[i]) + fonts[i]->SetData(FontData[code][i]); + } + } +} + +void cFont::SetFont(eDvbFont Font, void *Data) +{ + delete fonts[Font]; + fonts[Font] = new cFont(Data ? Data : FontData[code][Font]); +} + +const cFont *cFont::GetFont(eDvbFont Font) +{ + if (!fonts[Font]) + SetFont(Font); + return fonts[Font]; +} |