Ticket #451: navit-rtl.patch

File navit-rtl.patch, 4.7 KB (added by baruch.myopenid.com, 11 years ago)

Right-To-Left support for navit

  • autogen.sh

    diff --git a/autogen.sh b/autogen.sh
    index de55bc8..e1a5447 100755
    a b  
    11#!/bin/sh
    2 if [ `uname` == Darwin ]; then
     2if [ `uname` = Darwin ]; then
    33        LIBTOOL=glibtool
    44else
    55        LIBTOOL=libtool
  • configure.in

    diff --git a/configure.in b/configure.in
    index beb4278..2a70c8f 100644
    a b binding_dbus=yes; binding_dbus_reason=default 
    3939binding_python=yes; binding_python_reason=default
    4040font_freetype=yes; font_freetype_reason=default
    4141fontconfig=yes; fontconfig_reason=default
     42fribidi=yes; fribidi_reason=default
    4243gui_gtk=no; gui_gtk_reason=default
    4344gui_win32=no; gui_win32_reason=default
    4445gui_internal=yes; gui_internal_reason=default
    else 
    226227                [plugins="no"; plugins_reason="package gmodule and dlopen missing"]
    227228        )
    228229fi
     230
     231# fribidi
     232AC_ARG_ENABLE(fribidi, [  --disable-fribidi      dont build with fribidi], fribidi=$enableval, fribidi=yes)
     233if test x"${fribidi}" = "xyes"; then
     234        AC_CHECK_LIB(fribidi, fribidi_log2vis,
     235                     [FRIBIDI_LIBS=AC_DEFINE(USE_FRIBIDI, 1, [Define to 1 if you want to use fribidi])],
     236                     [fribidi="no"; fribidi_reason="fribidi library is missing"]
     237        )
     238    if test x"${fribidi}" = "xyes"; then
     239                AC_PATH_PROG([FRIBIDICONFIG], [fribidi-config], [])
     240        FRIBIDI_CFLAGS="`${FRIBIDICONFIG} --cflags`"
     241        FRIBIDI_LIBS="`${FRIBIDICONFIG} --libs`"
     242    fi
     243fi
     244
    229245# plugins
    230246AC_ARG_ENABLE(plugins,  [  --disable-plugins          disable plugins], [ plugins=$enableval;plugin_reason="configure parameter" ])
    231247if test "x${plugins}" = "xyes"; then
    AC_SUBST(PYTHON_LIBS) 
    501517AM_CONDITIONAL(BINDING_PYTHON, test "x${binding_python}" = "xyes")
    502518
    503519# dbus
    504 AC_ARG_ENABLE(binding-dbus,   [  --disable-binding-dbus               don't create binding dbus], binding_dbus=$enableval;binding_dbus_reason="configure parameter")
     520AC_ARG_ENABLE(binding-dbus,   [  --disable-binding-dbus               don't create binding dbus], binding_dbus=$enableval;binding_dbus_reason="configure parameter") #'
    505521if test "x${binding_dbus}" = "xyes" ; then
    506522        PKG_CHECK_MODULES(DBUS, [dbus-glib-1], ,binding_dbus=no)
    507523fi
    then 
    759775fi
    760776AC_SUBST(IPHONE_CFLAGS)
    761777AC_SUBST(IPHONE_LIBS)
    762 NAVIT_CFLAGS="$NAVIT_CFLAGS $GLIB_CFLAGS $GMODULE_CFLAGS"
    763 NAVIT_LIBS="$NAVIT_LIBS $GLIB_LIBS $GMODULE_LIBS $LIBINTL"
     778NAVIT_CFLAGS="$NAVIT_CFLAGS $GLIB_CFLAGS $GMODULE_CFLAGS $FRIBIDI_CFLAGS"
     779NAVIT_LIBS="$NAVIT_LIBS $GLIB_LIBS $GMODULE_LIBS $LIBINTL $FRIBIDI_LIBS"
    764780AC_SUBST(NAVIT_CFLAGS)
    765781AC_SUBST(NAVIT_LIBS)
    766782AC_SUBST(WORDEXP_LIBS)
    echo "Samplemap: $samplemap ($samplemap_reason)" 
    883899echo "NLS Support:         $enable_nls ($nls_libs)"
    884900echo "Font renderers:"
    885901echo "  freetype:          $font_freetype ($font_freetype_reason)"
     902echo "  fribidi            $fribidi"
    886903echo "Graphics types:"
    887904echo "  android:  $graphics_android ($graphics_android_reason)"
    888905echo "  gtk_drawing_area:  $graphics_gtk_drawing_area ($graphics_gtk_drawing_area_reason)"
  • navit/font/freetype/Makefile.am

    diff --git a/navit/font/freetype/Makefile.am b/navit/font/freetype/Makefile.am
    index e5557fe..6f99c2a 100644
    a b else 
    66  noinst_LTLIBRARIES = libfont_freetype.la
    77endif
    88libfont_freetype_la_SOURCES = font_freetype.c font_freetype.h
    9 libfont_freetype_la_LDFLAGS = @FREETYPE2_LIBS@ @FONTCONFIG_LIBS@ -module -avoid-version
     9libfont_freetype_la_LDFLAGS = @NAVIT_LIBS@ @FREETYPE2_LIBS@ @FONTCONFIG_LIBS@ -module -avoid-version
  • navit/font/freetype/font_freetype.c

    diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c
    index 313d279..0bf8eb0 100644
    a b  
    1919#include "color.h"
    2020#include "atom.h"
    2121#include "font_freetype.h"
     22#if USE_FRIBIDI
     23#include <fribidi/fribidi.h>
     24#endif
    2225
    2326#ifndef HAVE_LOOKUP_SCALER
    2427#if FREETYPE_MAJOR * 10000 + FREETYPE_MINOR * 100 + FREETYPE_PATCH > 20304
    font_freetype_text_new(char *text, struct font_freetype_font *font, int dx, 
    192198#if !USE_CACHING
    193199        FT_Set_Transform(font->face, &matrix, &pen);
    194200#endif
     201#if USE_FRIBIDI
     202    // Need to use fribidi to handle the string properly
     203    char visual_text[len*4+1];
     204    {
     205        FriBidiChar unicode_text[len+1];
     206        FriBidiChar visual_unicode_text[len+1];
     207        int unicode_len = fribidi_utf8_to_unicode(text, strlen(text), unicode_text);
     208        FriBidiCharType base = FRIBIDI_TYPE_LTR;
     209        fribidi_boolean fribidi_ret = fribidi_log2vis(unicode_text, unicode_len, &base, visual_unicode_text, NULL, NULL, NULL);
     210        // TODO: check return value
     211        fribidi_unicode_to_utf8(visual_unicode_text, unicode_len, visual_text);
     212        p = visual_text;
     213    }
     214#endif
    195215
    196216        for (n = 0; n < len; n++) {
    197217