diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-01-13 09:45:08 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-01-13 09:45:08 +0100 |
commit | 0730f502c5cc8253063d8d1bc7f769fcffc83155 (patch) | |
tree | f786d021644589952e84cc18d608f88b9fe13f4c /font.c | |
parent | ea6c6d370e21644c568cbf695669559f75dfa5ce (diff) | |
download | vdr-0730f502c5cc8253063d8d1bc7f769fcffc83155.tar.gz vdr-0730f502c5cc8253063d8d1bc7f769fcffc83155.tar.bz2 |
BIDI support now checks at runtime whether the system runs with UTF-8
Diffstat (limited to 'font.c')
-rw-r--r-- | font.c | 40 |
1 files changed, 21 insertions, 19 deletions
@@ -6,7 +6,7 @@ * * BiDi support by Osama Alrawab <alrawab@hotmail.com> @2008 Tripoli-Libya. * - * $Id: font.c 2.8 2011/03/28 16:29:51 kls Exp $ + * $Id: font.c 2.9 2012/01/13 09:43:22 kls Exp $ */ #include "font.h" @@ -508,25 +508,27 @@ cString cFont::GetFontFileName(const char *FontName) #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 + 1); - fribidi_unicode_to_charset(fribidiCharset, Visual, RtlLen, Rtl); + if (cCharSetConv::SystemCharacterTable()) { // bidi requires UTF-8 + 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 + 1); + fribidi_unicode_to_charset(fribidiCharset, Visual, RtlLen, Rtl); + } + free(Logical); + free(Visual); + if (ok) + return cString(Rtl, true); } - free(Logical); - free(Visual); - if (ok) - return cString(Rtl, true); return cString(Ltr); } #endif |