Ticket #4191: osd_rtl_support.2.patch

File osd_rtl_support.2.patch, 3.7 KB (added by thelinuxer@…, 13 years ago)

This is our final patch for OSD fribidi support. It solves the problem with linking to fribidi is not automatically set by the configure script. It also splits the code in two paths: If fribidi exists, the code will attempt to use Fribidi rtl conversion. If not, it will revert to the simple method that exists today in Mythtv (the ConvertFromRtl? method, which doesn't support complex languages like Arabic)

  • configure

     
    23742374check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
    23752375
    23762376##########################################
     2377# fribidi check
     2378
     2379disable fribidi
     2380FRIBIDI_CONFIG="pkg-config fribidi"
     2381if ( pkg-config fribidi --version ) >/dev/null 2>&1 ; then
     2382        _fribidi_version=`${FRIBIDI_CONFIG} --version | sed 's/[^0-9]//g'`
     2383        if test "$_fribidi_version" -lt 022 ; then
     2384                disable fribidi
     2385        else
     2386
     2387                check_cc `${FRIBIDI_CONFIG} --cflags` `${FRIBIDI_CONFIG} --libs` << EOF && enable fribidi               
     2388#include <stdio.h>
     2389#include <fribidi/fribidi.h>
     2390int main()
     2391{
     2392  if(fribidi_parse_charset("UTF-8") != FRIBIDI_CHAR_SET_UTF8) {
     2393    printf("Fribidi headers are not consistents with the library!\n");
     2394    exit(1);
     2395  }
     2396  return 0;
     2397}
     2398EOF
     2399               
     2400        fi
     2401
     2402fi
     2403##########################################
    23772404# SDL check
    23782405
    23792406disable sdl_too_old
     
    29042931BLOCK_QUOTE
    29052932
    29062933echo
     2934if test x"$frontend" = x"yes" ; then
     2935  echo "# OSD Bidi languages support"
     2936  echo "Fribi present    $fribidi"
     2937fi
     2938
     2939echo
    29072940if enabled frontend; then
    29082941  echo "# Input Support"
    29092942  echo "Joystick menu             ${joystick_menu-no}"
     
    30373070  echo "FREETYPE_CFLAGS=`freetype-config --cflags`" >> $MYTH_CONFIG_MAK
    30383071  echo "FREETYPE_LIBS=`freetype-config --libs`" >> $MYTH_CONFIG_MAK
    30393072fi
     3073if enabled fribidi; then
     3074  echo "#define HAVE_FRIBIDI 1" >> $TMPH
     3075  echo "HAVE_FRIBIDI=yes" >> $MYTH_CONFIG_MAK
     3076  echo "FRIBIDI_LIBS=`${FRIBIDI_CONFIG} --libs`" >> $MYTH_CONFIG_MAK
     3077  echo "FRIBIDI_CFLAGS=`${FRIBIDI_CONFIG} --cflags`" >> $MYTH_CONFIG_MAK
     3078fi
    30403079if enabled sdl; then
    30413080  echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> $MYTH_CONFIG_MAK
    30423081  echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> $MYTH_CONFIG_MAK
  • settings.pro

     
    9999EXTRA_LIBS += $$CONFIG_XRANDR_LIBS
    100100EXTRA_LIBS += $$CONFIG_XVMC_LIBS
    101101EXTRA_LIBS += $$CONFIG_OPENGL_LIBS
     102EXTRA_LIBS += $$FRIBIDI_LIBS
    102103
    103104LIRC_LIBS = $$CONFIG_LIRC_LIBS
  • libs/libmythtv/osdtypes.cpp

     
    1616#include "mythcontext.h"
    1717#include "mythdialogs.h"
    1818
     19#include "../libmyth/mythconfig.h"
     20#ifdef HAVE_FRIBIDI
     21        #include "fribidi/fribidi.h"
     22        #include <qtextcodec.h>
     23#endif
     24
    1925/// Shared OSD image cache
    2026OSDImageCache OSDTypeImage::c_cache;
    2127
     
    790796        }
    791797    }
    792798
    793     return QDeepCopy<QString>(rtl_string_composer.join(""));
     799    QString output = rtl_string_composer.join("");
     800
     801#ifdef HAVE_FRIBIDI
     802
     803    static QTextCodec *codeci =NULL;
     804    if (codeci==NULL) codeci = QTextCodec::codecForName("utf8");
     805               
     806    QCString temp = codeci->fromUnicode(output);
     807                       
     808    FriBidiCharType base;
     809    size_t len;
     810       
     811    bool fribidi_flip_commas = true;                   
     812    base = fribidi_flip_commas?FRIBIDI_TYPE_ON:FRIBIDI_TYPE_L;
     813                       
     814    const char* ip = temp;
     815    FriBidiChar logical[strlen(ip)+1], visual[strlen(ip)+1];
     816               
     817    int char_set_num = fribidi_parse_charset ("UTF-8");
     818
     819    len = fribidi_charset_to_unicode ((FriBidiCharSet)char_set_num, ip, strlen(ip), logical);
     820               
     821    bool log2vis = fribidi_log2vis (logical, len, &base,                       
     822        visual, NULL, NULL, NULL); // output
     823               
     824    if(log2vis)
     825        len = fribidi_remove_bidi_marks (visual, len, NULL, NULL,NULL);
     826                           
     827    output = "";
     828    for (int i = 0; i < len ; i++)
     829        output+=QChar(visual[i]);
     830           
     831#endif //HAVE_FRIBIDI
     832    return QDeepCopy<QString>(output);
    794833}
    795834
    796835void OSDTypeText::SetText(const QString &text)