summaryrefslogtreecommitdiff
path: root/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'font.c')
-rw-r--r--font.c78
1 files changed, 63 insertions, 15 deletions
diff --git a/font.c b/font.c
index 22c92be..f25136c 100644
--- a/font.c
+++ b/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.2 2000/11/18 15:16:08 kls Exp $
+ * $Id: font.c 1.4 2003/10/24 12:59:35 kls Exp $
*/
#include "font.h"
@@ -12,24 +12,38 @@
#include "fontfix.c"
#include "fontosd.c"
+#include "fontsml.c"
-cFont::cFont(eDvbFont Font)
-{
+#include "fontfix-iso8859-7.c"
+#include "fontosd-iso8859-7.c"
+#include "fontsml-iso8859-7.c"
+
+static void *FontData[eDvbCodeSize][eDvbFontSize] = {
+ { FontOsd_iso8859_1, FontFix_iso8859_1, FontSml_iso8859_1 },
+ { FontOsd_iso8859_7, FontFix_iso8859_7, FontSml_iso8859_7 }
+ };
+
+static const char *FontCode[eDvbCodeSize] = {
+ "iso8859-1",
+ "iso8859-7"
+ };
-#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 +51,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 +59,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];
+}