Changed font handling to allow language specific character sets; adopted the small font character set from the "Elchi" patch

This commit is contained in:
Klaus Schmidinger
2003-10-24 12:53:12 +02:00
parent 2b29a5ce36
commit c94570e69d
14 changed files with 5738 additions and 47 deletions

74
font.c
View File

@@ -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",
};
eDvbCode cFont::code = code_iso8859_1;
cFont *cFont::fonts[eDvbFontSize] = { NULL };
cFont::cFont(void *Data)
{
#define FONTINDEX(Name)\
case font##Name: for (int i = 0; i < NUMCHARS; i++)\
data[i] = (tCharData *)&Font##Name[i < 32 ? 0 : i - 32];\
break;
switch (Font) {
default:
FONTINDEX(Osd);
FONTINDEX(Fix);
// TODO others...
}
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];
}