revised fribidi support:

* Updated to support both fribidi2 (>= 0.19.0) and old fribidi (>= 0.10.9)

 * The cmake part was done by Mark with some fixes add by me.

 * I tested on Fedora-11, Mark tested on Debian stable.
This commit is contained in:
Oron Peled 2009-08-01 18:28:18 +00:00
parent ae2beedff6
commit e35f199086
5 changed files with 60 additions and 21 deletions

View file

@ -26,7 +26,7 @@ find_package( Boost 1.35 REQUIRED COMPONENTS iostreams regex )
# yes, gettext is *required* even when NLS is deactivated (this is to compile
# src/gettext.cpp since it includes libintl.h)
find_package( Gettext REQUIRED )
find_package( FriBiDi )
find_package( X11 )
if(NOT MSVC)
@ -154,12 +154,6 @@ if(GUI STREQUAL "tiny")
add_definitions(-DUSE_TINY_GUI)
endif(GUI STREQUAL "tiny")
if(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
add_definitions(-DHAVE_FRIBIDI)
elseif(ENABLE_FRIBIDI AND NOT FRIBIDI_LIBRARIES)
message("Could not find FriBiDi. Disabling FriBiDi support.")
endif()
if(ENABLE_LOW_MEM)
add_definitions(-DLOW_MEM)
endif(ENABLE_LOW_MEM)
@ -192,10 +186,19 @@ endif(ENABLE_TESTS)
if(ENABLE_GAME)
find_package( Lua51 REQUIRED)
find_package( PkgConfig REQUIRED )
pkg_check_modules( PANGOCAIRO REQUIRED pangocairo>=1.14.8 )
if(NOT MSVC)
pkg_check_modules( FONTCONFIG REQUIRED fontconfig>=2.4.1 )
endif(NOT MSVC)
find_package( FriBiDi )
if(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
add_definitions(-DHAVE_FRIBIDI)
elseif(ENABLE_FRIBIDI AND NOT FRIBIDI_LIBRARIES)
message("Could not find FriBiDi. Disabling FriBiDi support.")
endif()
endif(ENABLE_GAME)
# get languages

View file

@ -13,10 +13,13 @@ include(CheckSymbolExists)
SET(FRIBIDI_FOUND "NO")
FIND_PATH(FRIBIDI_INCLUDE_DIR fribidi/fribidi.h
/usr/local/include
/usr/include
# Set variable in temp var, otherwise FIND_PATH might fail
# unset isn't present in the required version of cmake.
FIND_PATH(xFRIBIDI_INCLUDE_DIR fribidi.h
/usr/local/include/fribidi
/usr/include/fribidi
)
set(FRIBIDI_INCLUDE_DIR ${xFRIBIDI_INCLUDE_DIR})
SET(FRIBIDI_NAMES ${FRIBIDI_NAMES} fribidi libfribidi)
FIND_LIBRARY(FRIBIDI_LIBRARY
@ -27,12 +30,16 @@ FIND_LIBRARY(FRIBIDI_LIBRARY
IF (FRIBIDI_LIBRARY AND FRIBIDI_INCLUDE_DIR)
SET(CMAKE_REQUIRED_INCLUDES ${FRIBIDI_INCLUDE_DIR})
SET(CMAKE_REQUIRED_LIBRARIES ${FRIBIDI_LIBRARY})
#we only support version 1 of fribidi and need the symbol fribidi_utf8_to_unicode
#here we check if it is really available
CHECK_SYMBOL_EXISTS(fribidi_utf8_to_unicode fribidi/fribidi.h FOUND_fribidi_utf8_to_unicode)
if(FOUND_fribidi_utf8_to_unicode)
CHECK_SYMBOL_EXISTS(fribidi_utf8_to_unicode fribidi.h FOUND_fribidi_utf8_to_unicode)
CHECK_SYMBOL_EXISTS(fribidi_charset_to_unicode fribidi.h FOUND_fribidi_charset_to_unicode)
if(FOUND_fribidi_charset_to_unicode)
SET(FRIBIDI_LIBRARIES ${FRIBIDI_LIBRARY})
SET(FRIBIDI_FOUND "YES")
elseif(FOUND_fribidi_utf8_to_unicode)
SET(FRIBIDI_LIBRARIES ${FRIBIDI_LIBRARY})
SET(FRIBIDI_FOUND "YES")
add_definitions(-DOLD_FRIBIDI)
MESSAGE(STATUS "Legacy FriBiDi: ${FRIBIDI_LIBRARY}")
else()
SET(FRIBIDI_LIBRARIES "NOTFOUND")
SET(FRIBIDI_INCLUDE_DIR "NOTFOUND")
@ -43,7 +50,7 @@ ENDIF (FRIBIDI_LIBRARY AND FRIBIDI_INCLUDE_DIR)
IF (FRIBIDI_FOUND)
IF (NOT FRIBIDI_FIND_QUIETLY)
MESSAGE(STATUS "Found FriBiDi: ${FRIBIDI_LIBRARY}")
MESSAGE(STATUS "Using FriBiDi: ${FRIBIDI_LIBRARY}")
ENDIF (NOT FRIBIDI_FIND_QUIETLY)
ELSE (FRIBIDI_FOUND)
IF (FRIBIDI_FIND_REQUIRED)

View file

@ -417,10 +417,24 @@ fi
# fribidi-config
if test "x$fribidi" != "xno"; then
PKG_CHECK_MODULES([FRIBIDI], [fribidi >= 0.10.9],
[ fribidifound=yes ],
[ fribidifound=no ])
PKG_CHECK_MODULES([FRIBIDI2], [fribidi >= 0.19.0],
[
fribidifound=yes
],
[
AC_MSG_RESULT(no)
PKG_CHECK_MODULES([FRIBIDI], [fribidi],
[
fribidifound=yes
oldfribidi=yes
],
[
fribidifound=no
AC_MSG_RESULT(no)
])
])
AM_CONDITIONAL([FRIBIDI], [test "x$fribidifound" = xyes])
AM_CONDITIONAL([OLD_FRIBIDI], [test "x$oldfribidi" = xyes])
fi
# python

View file

@ -485,9 +485,15 @@ AM_CFLAGS = -DHAVE_REVISION -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOT
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR)
if FRIBIDI
AM_CXXFLAGS += -DHAVE_FRIBIDI @FRIBIDI_CFLAGS@
AM_CFLAGS += -DHAVE_FRIBIDI @FRIBIDI_CFLAGS@
if OLD_FRIBIDI
CXXFLAGS += -DOLD_FRIBIDI @FRIBIDI_CFLAGS@
CFLAGS += -DOLD_FRIBIDI @FRIBIDI_CFLAGS@
THELIBS += @FRIBIDI_LIBS@
else
CXXFLAGS += -DHAVE_FRIBIDI @FRIBIDI2_CFLAGS@
CFLAGS += -DHAVE_FRIBIDI @FRIBIDI2_CFLAGS@
THELIBS += @FRIBIDI2_LIBS@
endif
endif
if X11

View file

@ -50,7 +50,7 @@ static lg::log_domain log_font("font");
#define ERR_FT LOG_STREAM(err, log_font)
#ifdef HAVE_FRIBIDI
#include <fribidi/fribidi.h>
#include <fribidi.h>
#endif
namespace {
@ -471,9 +471,18 @@ void text_surface::bidi_cvt()
FriBidiCharType base_dir = FRIBIDI_TYPE_ON;
FriBidiStrIndex n;
#ifdef OLD_FRIBIDI
n = fribidi_utf8_to_unicode (c_str, len, bidi_logical);
#else
n = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8, c_str, len, bidi_logical);
#endif
fribidi_log2vis(bidi_logical, n, &base_dir, bidi_visual, NULL, NULL, NULL);
#ifdef OLD_FRIBIDI
fribidi_unicode_to_utf8 (bidi_visual, n, utf8str);
#else
fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8, bidi_visual, n, utf8str);
#endif
is_rtl_ = base_dir == FRIBIDI_TYPE_RTL;
str_ = std::string(utf8str);
delete[] bidi_logical;