Added support for languages that are written right-to-left

This commit is contained in:
Klaus Schmidinger 2010-09-19 12:36:07 +02:00
parent f1d4e66582
commit ab0beb2ddb
8 changed files with 79 additions and 14 deletions

View File

@ -2621,3 +2621,7 @@ Stefan Huskamp <coca_cola1@gmx.de>
Cristiano A. Silva <arquithek@gmail.com>
for updating the Portuguese language texts
Osama Alrawab <alrawab@hotmail.com>
for adding support for languages that are written right-to-left
for translating OSD texts to the Arabian language

View File

@ -6465,12 +6465,11 @@ Video Disk Recorder Revision History
the number keys can be used to enter characters in a text input field (suggested
by Stefan Huskamp).
2010-08-29: Version 1.7.16
2010-09-19: Version 1.7.16
- Updated the Italian OSD texts (thanks to Diego Pierotto).
- Added missing Dtypes for ATSC (thanks to Alex Lasnier).
- Updated the Portuguese language texts (thanks to Cristiano A.
Silva).
- Updated the Portuguese language texts (thanks to Cristiano A. Silva).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
- Fixed the array size of Atypes in cPatFilter::Process() (thanks to
Rolf Ahrenberg).
@ -6478,3 +6477,6 @@ Video Disk Recorder Revision History
is called from a plugin (reported by Andreas Mair).
- Fixed DDS detection for HD resolution subtitles (thanks to Reinhard Nissl).
- Fixed following symbolic links in RemoveFileOrDir().
- Added support for languages that are written right-to-left (based on a patch
from Osama Alrawab). See INSTALL for information on how to turn this on.
- Added Arabian language texts (thanks to Osama Alrawab).

11
INSTALL
View File

@ -23,6 +23,7 @@ You will also need to install the following libraries, as well as their
fontconfig
freetype2
fribidi (see "BiDi support" below)
gettext
libcap
libjpeg
@ -111,6 +112,16 @@ in English.
Note that for VDR's internationalized texts to work, the LANG environment
variable must be set to a valid locale!
BiDi support
------------
Some languages are written right-to-left. In order to display such languages
correctly, you need to build VDR with BIDI=1. This will link to the "fribidi"
library and implement a function that prepares bidirectional texts to be
displayed correctly. Since BiDi support adds some runtime overhead by requiring
additional memory allocation and copying, this feature is not compiled in
by default, so that users that have no need for this don't get any overhead.
Workaround for providers not encoding their EPG data correctly
--------------------------------------------------------------

View File

@ -4,7 +4,7 @@
# See the main source file 'vdr.c' for copyright information and
# how to reach the author.
#
# $Id: Makefile 2.9 2010/04/10 12:40:15 kls Exp $
# $Id: Makefile 2.10 2010/09/17 13:28:50 kls Exp $
.DELETE_ON_ERROR:
@ -53,6 +53,11 @@ endif
ifdef VDR_USER
DEFINES += -DVDR_USER=\"$(VDR_USER)\"
endif
ifdef BIDI
INCLUDES += -I/usr/include/fribidi
DEFINES += -DBIDI
LIBS += -lfribidi
endif
LIRC_DEVICE ?= /dev/lircd
RCU_DEVICE ?= /dev/ttyS1

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: config.h 2.27 2010/06/06 09:53:02 kls Exp $
* $Id: config.h 2.28 2010/09/12 11:31:21 kls Exp $
*/
#ifndef __CONFIG_H
@ -22,13 +22,13 @@
// VDR's own version number:
#define VDRVERSION "1.7.15"
#define VDRVERSNUM 10715 // Version * 10000 + Major * 100 + Minor
#define VDRVERSION "1.7.16"
#define VDRVERSNUM 10716 // Version * 10000 + Major * 100 + Minor
// The plugin API's version number:
#define APIVERSION "1.7.15"
#define APIVERSNUM 10715 // Version * 10000 + Major * 100 + Minor
#define APIVERSION "1.7.16"
#define APIVERSNUM 10716 // Version * 10000 + Major * 100 + Minor
// When loading plugins, VDR searches them by their APIVERSION, which
// may be smaller than VDRVERSION in case there have been no changes to

41
font.c
View File

@ -4,12 +4,17 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: font.c 2.4 2009/12/31 14:49:59 kls Exp $
* BiDi support by Osama Alrawab <alrawab@hotmail.com> @2008 Tripoli-Libya.
*
* $Id: font.c 2.5 2010/09/19 11:49:19 kls Exp $
*/
#include "font.h"
#include <ctype.h>
#include <fontconfig/fontconfig.h>
#ifdef BIDI
#include <fribidi.h>
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#include "config.h"
@ -240,6 +245,10 @@ int cFreetypeFont::Width(const char *s) const
{
int w = 0;
if (s) {
#ifdef BIDI
cString bs = Bidi(s);
s = bs;
#endif
uint prevSym = 0;
while (*s) {
int sl = Utf8CharLen(s);
@ -259,6 +268,10 @@ int cFreetypeFont::Width(const char *s) const
void cFreetypeFont::DrawText(cBitmap *Bitmap, int x, int y, const char *s, tColor ColorFg, tColor ColorBg, int Width) const
{
if (s && height) { // checking height to make sure we actually have a valid font
#ifdef BIDI
cString bs = Bidi(s);
s = bs;
#endif
bool AntiAliased = Setup.AntiAlias && Bitmap->Bpp() >= 8;
bool TransparentBackground = ColorBg == clrTransparent;
int16_t BlendLevelIndex[MAX_BLEND_LEVELS]; // tIndex is 8 bit unsigned, so a negative value can be used to mark unused entries
@ -443,6 +456,32 @@ cString cFont::GetFontFileName(const char *FontName)
return FontFileName;
}
#ifdef BIDI
cString cFont::Bidi(const char *Ltr)
{
fribidi_set_mirroring(true);
fribidi_set_reorder_nsm(false);
FriBidiCharSet fribidiCharset = FRIBIDI_CHAR_SET_UTF8;
int LtrLen = strlen(Ltr);
FriBidiCharType Base = FRIBIDI_TYPE_L;
FriBidiChar *Logical = MALLOC(FriBidiChar, LtrLen + 1) ;
int RtlLen = fribidi_charset_to_unicode(fribidiCharset, const_cast<char *>(Ltr), LtrLen, Logical);
FriBidiChar *Visual = MALLOC(FriBidiChar, LtrLen + 1) ;
char *Rtl = NULL;
bool ok = fribidi_log2vis(Logical, RtlLen, &Base, Visual, NULL, NULL, NULL);
if (ok) {
fribidi_remove_bidi_marks(Visual, RtlLen, NULL, NULL, NULL);
Rtl = MALLOC(char, RtlLen * 4);
fribidi_unicode_to_charset(fribidiCharset, Visual, RtlLen, Rtl);
}
free(Logical);
free(Visual);
if (ok)
return cString(Rtl, true);
return cString(Ltr);
}
#endif
// --- cTextWrapper ----------------------------------------------------------
cTextWrapper::cTextWrapper(void)

7
font.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: font.h 2.3 2009/12/31 14:48:25 kls Exp $
* $Id: font.h 2.4 2010/09/19 11:48:37 kls Exp $
*/
#ifndef __FONT_H
@ -82,6 +82,11 @@ public:
///< Returns true if any font names were found.
static cString GetFontFileName(const char *FontName);
///< Retruns the actual font file name for the given FontName.
#ifdef BIDI
static cString Bidi(const char *Ltr);
///< Converts any "right-to-left" parts in the "left-to-right" string Ltr
///< to the proper language specific representation and returns the resulting string.
#endif
};
class cTextWrapper {

5
i18n.c
View File

@ -4,9 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: i18n.c 2.1 2008/09/06 12:24:43 kls Exp $
*
*
* $Id: i18n.c 2.2 2010/09/19 11:22:39 kls Exp $
*/
/*
@ -60,6 +58,7 @@ const char *LanguageCodeList[] = {
"cze,ces",
"tur",
"ukr",
"ara",
NULL
};