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

View File

@ -853,3 +853,6 @@ Thomas Rausch <Thomas.Rausch@gmx.de>
Emil Petersky <petersky@isr.uni-stuttgart.de>
for adding "Slovak Link" and "Czech Link" to 'ca.conf'
Alessio Sangalli <alesan@manoweb.com>
for providing the iso8859-1 small font

View File

@ -2438,7 +2438,7 @@ Video Disk Recorder Revision History
- Improved cDvbDevice::StillPicture() (thanks to Thomas Heiligenmann).
2003-10-18: Version 1.3.0
2003-10-24: Version 1.3.0
- Changed thread handling to make it work with NPTL ("Native Posix Thread Library").
Thanks to Jon Burgess, Andreas Schultz, Werner Fink and Stefan Huelswitt.
@ -2452,3 +2452,6 @@ Video Disk Recorder Revision History
- Added "Slovak Link" and "Czech Link" to 'ca.conf' (thanks to Emil Petersky).
- Mutexes are now created with PTHREAD_MUTEX_ERRORCHECK_NP, which makes the
'lockingTid' stuff obsolete (thanks to Stefan Huelswitt).
- Changed font handling to allow language specific character sets.
- Adopted the small font character set from the "Elchi" patch (originally
provided by Alessio Sangalli).

View File

@ -4,7 +4,7 @@
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
# $Id: Makefile 1.58 2003/08/09 11:09:45 kls Exp $
# $Id: Makefile 1.59 2003/10/24 12:53:12 kls Exp $
.DELETE_ON_ERROR:
@ -39,8 +39,9 @@ OBJS = audio.o channels.o ci.o config.o cutter.o device.o diseqc.o dvbdevice.o d
receiver.o recorder.o recording.o remote.o remux.o ringbuffer.o sources.o\
spu.o status.o svdrp.o thread.o timers.o tools.o transfer.o vdr.o videodir.o
OSDFONT = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1
FIXFONT = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1
FIXFONT_ISO8859_1 = -adobe-courier-bold-r-normal--25-*-100-100-m-*-iso8859-1
OSDFONT_ISO8859_1 = -adobe-helvetica-medium-r-normal--23-*-100-100-p-*-iso8859-1
SMLFONT_ISO8859_1 = -adobe-helvetica-medium-r-normal--18-*-100-100-p-*-iso8859-1
ifndef NO_KBD
DEFINES += -DREMOTE_KBD
@ -64,7 +65,7 @@ DEFINES += -DVFAT
endif
all: vdr
font: genfontfile fontfix.c fontosd.c
font: genfontfile fontfix.c fontosd.c fontsml.c
@echo "font files created."
# Implicit rules:
@ -89,9 +90,11 @@ vdr: $(OBJS) $(DTVLIB)
# The font files:
fontfix.c:
./genfontfile "cFont::tPixelData FontFix" "$(FIXFONT)" > $@
./genfontfile "cFont::tPixelData FontFix_iso8859_1" "$(FIXFONT_ISO8859_1)" > $@
fontosd.c:
./genfontfile "cFont::tPixelData FontOsd" "$(OSDFONT)" > $@
./genfontfile "cFont::tPixelData FontOsd_iso8859_1" "$(OSDFONT_ISO8859_1)" > $@
fontsml.c:
./genfontfile "cFont::tPixelData FontSml_iso8859_1" "$(SMLFONT_ISO8859_1)" > $@
# The font file generator:
@ -145,6 +148,6 @@ clean:
-rm -rf include
-rm -rf srcdoc
fontclean:
-rm -f fontfix.c fontosd.c
-rm -f fontfix.c fontosd.c fontsml.c
CLEAN: clean fontclean

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];
}

34
font.h
View File

@ -4,19 +4,24 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: font.h 1.2 2000/11/18 14:51:45 kls Exp $
* $Id: font.h 1.3 2003/10/24 12:52:46 kls Exp $
*/
#ifndef __FONT_H
#define __FONT_H
#include <stdlib.h>
enum eDvbFont {
fontOsd,
fontFix,
/* TODO as soon as we have the font files...
fontTtxSmall,
fontTtxLarge,
*/
fontSml
#define eDvbFontSize (fontSml + 1)
};
enum eDvbCode {
code_iso8859_1,
#define eDvbCodeSize (code_iso8859_1 + 1)
};
class cFont {
@ -28,14 +33,21 @@ public:
tPixelData lines[1];
};
private:
static eDvbCode code;
static cFont *fonts[];
const tCharData *data[NUMCHARS];
public:
cFont(eDvbFont Font);
int Width(unsigned char c) { return data[c]->width; }
int Width(const char *s);
int Height(unsigned char c) { return data[c]->height; }
int Height(const char *s);
const tCharData *CharData(unsigned char c) { return data[c]; }
cFont(void *Data);
void SetData(void *Data);
int Width(unsigned char c) const { return data[c]->width; }
int Width(const char *s) const;
int Height(unsigned char c) const { return data[c]->height; }
int Height(const char *s) const;
const tCharData *CharData(unsigned char c) const { return data[c]; }
static bool SetCode(const char *Code);
static void SetCode(eDvbCode Code);
static void SetFont(eDvbFont Font, void *Data = NULL);
static const cFont *GetFont(eDvbFont Font);
};
#endif //__FONT_H

View File

@ -1,4 +1,4 @@
cFont::tPixelData FontFix[][28] = {
cFont::tPixelData FontFix_iso8859_1[][28] = {
{ // 32
15, 26,
0x00000000, // ...............

View File

@ -1,4 +1,4 @@
cFont::tPixelData FontOsd[][29] = {
cFont::tPixelData FontOsd_iso8859_1[][29] = {
{ // 32
6, 27,
0x00000000, // ......

5602
fontsml.c Normal file

File diff suppressed because it is too large Load Diff

25
i18n.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: i18n.c 1.134 2003/09/11 13:51:56 kls Exp $
* $Id: i18n.c 1.135 2003/10/24 12:45:39 kls Exp $
*
* Translations provided by:
*
@ -88,6 +88,24 @@ const tI18nPhrase Phrases[] = {
"Magyar",
"Català",
},
// The character set needed for this language (this MUST be the second phrase!):
{ "iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
"iso8859-1",
},
// Menu titles:
{ "VDR",
"VDR",
@ -3824,3 +3842,8 @@ const char * const * I18nLanguages(void)
{
return &Phrases[0][0];
}
const char * const * I18nCharSets(void)
{
return &Phrases[1][0];
}

3
i18n.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: i18n.h 1.6 2003/05/16 12:48:52 kls Exp $
* $Id: i18n.h 1.7 2003/10/19 15:02:05 kls Exp $
*/
#ifndef __I18N_H
@ -21,6 +21,7 @@ void I18nRegister(const tI18nPhrase * const Phrases, const char *Plugin);
const char *I18nTranslate(const char *s, const char *Plugin = NULL);
const char * const * I18nLanguages(void);
const char * const * I18nCharSets(void);
#ifdef PLUGIN_NAME_I18N
#define tr(s) I18nTranslate(s, PLUGIN_NAME_I18N)

4
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 1.273 2003/10/03 14:36:20 kls Exp $
* $Id: menu.c 1.274 2003/10/19 15:13:05 kls Exp $
*/
#include "menu.h"
@ -1985,6 +1985,7 @@ private:
virtual void Set(void);
public:
cMenuSetupOSD(void) { Set(); }
virtual ~cMenuSetupOSD() { cFont::SetCode(I18nCharSets()[Setup.OSDLanguage]); }
virtual eOSState ProcessKey(eKeys Key);
};
@ -2011,6 +2012,7 @@ eOSState cMenuSetupOSD::ProcessKey(eKeys Key)
if (data.OSDLanguage != osdLanguage) {
int OriginalOSDLanguage = Setup.OSDLanguage;
Setup.OSDLanguage = data.OSDLanguage;
cFont::SetCode(I18nCharSets()[Setup.OSDLanguage]);
Set();
Display();
Setup.OSDLanguage = OriginalOSDLanguage;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: osdbase.c 1.10 2003/08/24 11:38:27 kls Exp $
* $Id: osdbase.c 1.11 2003/10/19 14:32:32 kls Exp $
*/
#include "osdbase.h"
@ -131,7 +131,6 @@ cBitmap::cBitmap(int Width, int Height, int Bpp, bool ClearWithBackground)
cBitmap::~cBitmap()
{
delete font;
free(bitmap);
}
@ -139,8 +138,7 @@ eDvbFont cBitmap::SetFont(eDvbFont Font)
{
eDvbFont oldFont = fontType;
if (fontType != Font || !font) {
delete font;
font = new cFont(Font);
font = cFont::GetFont(Font);
fontType = Font;
}
return oldFont;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: osdbase.h 1.6 2002/09/08 14:12:41 kls Exp $
* $Id: osdbase.h 1.7 2003/10/19 14:32:32 kls Exp $
*/
#ifndef __OSDBASE_H
@ -73,7 +73,7 @@ public:
class cBitmap : public cPalette {
private:
cFont *font;
const cFont *font;
eDvbFont fontType;
char *bitmap;
bool clearWithBackground;

4
vdr.c
View File

@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/vdr
*
* $Id: vdr.c 1.169 2003/09/14 09:36:54 kls Exp $
* $Id: vdr.c 1.170 2003/10/19 15:14:42 kls Exp $
*/
#include <getopt.h>
@ -358,6 +358,8 @@ int main(int argc, char *argv[])
))
return 2;
cFont::SetCode(I18nCharSets()[Setup.OSDLanguage]);
// DVB interfaces:
cDvbDevice::Initialize();