[mapserver-commits] r7457 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Mar 17 14:44:51 EDT 2008
Author: dmorissette
Date: 2008-03-17 14:44:51 -0400 (Mon, 17 Mar 2008)
New Revision: 7457
Modified:
trunk/mapserver/Makefile.in
trunk/mapserver/configure
trunk/mapserver/configure.in
trunk/mapserver/maperror.c
trunk/mapserver/mapstring.c
Log:
Added FriBidi for left-to-right label support, e.g. Hebrew (#956)
Modified: trunk/mapserver/Makefile.in
===================================================================
--- trunk/mapserver/Makefile.in 2008-03-14 12:28:06 UTC (rev 7456)
+++ trunk/mapserver/Makefile.in 2008-03-17 18:44:51 UTC (rev 7457)
@@ -162,6 +162,12 @@
CURL_INC=@CURL_INC@
CURL_LIB=@CURL_LIB@
+# libfribibi ...
+FRIBIDI=@FRIBIDI_ENABLED@
+FRIBIDI_INC=@FRIBIDI_INC@
+FRIBIDI_LIB=@FRIBIDI_LIB@
+
+
# libxml2 ... required for OGC SOS Server
XML2_INC=@XML2_INC@
XML2_LIB=@XML2_LIB@
@@ -224,12 +230,12 @@
XTRALIBS= @XTRALIBS@
RUNPATHS= @RPATHS@
-DEFINES = $(IGNORE_MISSING_DATA) $(USE_POINT_Z_M) $(STRINGS) @ALL_ENABLED@
+DEFINES = $(IGNORE_MISSING_DATA) $(USE_POINT_Z_M) $(STRINGS) @ALL_ENABLED@ $(FRIBIDI)
INCLUDES = $(REGEX_INC) $(PNG_INC) $(GD_INC) $(AGG_INC) $(PDF_INC) $(PROJ_INC) $(TIFF_INC) $(JPEG_INC) $(EGIS_INC) \
$(SDE_INC) $(GDAL_INC) $(POSTGIS_INC) $(MYGIS_INC) \
$(CURL_INC) $(MING_INC) $(ORACLESPATIAL_INC) $(GEOS_INC) $(ICONV_INC) \
- $(FASTCGI_INC) $(ZLIB_INC) $(XML2_INC)
+ $(FASTCGI_INC) $(ZLIB_INC) $(XML2_INC) $(FRIBIDI_INC)
FLAGS = @DEBUG_FLAGS@ $(DEFINES) $(INCLUDES)
@@ -241,7 +247,7 @@
$(JPEG_LIB) $(PNG_LIB) $(SDE_LIB) $(GDAL_LIB) $(MING_LIB) $(POSTGIS_LIB) \
$(MYGIS_LIB) $(CURL_LIB) $(ORACLESPATIAL_LIB) $(GEOS_LIB) \
$(THREAD_LIB) $(ICONV_LIB) $(FASTCGI_LIB) \
- $(ZLIB_LIB) $(XML2_LIB) $(XTRALIBS)
+ $(ZLIB_LIB) $(XML2_LIB) $(FRIBIDI_LIB) $(XTRALIBS)
# STATIC_LIBS is full filename with path of libs that will be statically linked
STATIC_LIBS= $(GD_STATIC)
Modified: trunk/mapserver/configure
===================================================================
--- trunk/mapserver/configure 2008-03-14 12:28:06 UTC (rev 7456)
+++ trunk/mapserver/configure 2008-03-17 18:44:51 UTC (rev 7457)
@@ -742,6 +742,10 @@
LIBCURL_CONFIG
CURL_INC
CURL_LIB
+FRIBIDI_CONFIG
+FRIBIDI_ENABLED
+FRIBIDI_INC
+FRIBIDI_LIB
LIBXML2_CONFIG
XML2_INC
XML2_LIB
@@ -1428,6 +1432,8 @@
--with-sos Enable OGC SOS Server Support (libxml2 and PROJ4 and
OGR required).
--with-curl-config=PATH Specify path to curl-config.
+ --with-fribidi-config[=ARG] Include FriBidi Support (ARG=yes/path to
+ fribidi-config)
--with-xml2-config=PATH Specify path to xml2-config.
--with-fastcgi=path Enable FastCGI, point to installed tree.
--with-httpd Specify path to 'httpd' executable.
@@ -11474,6 +11480,92 @@
+{ echo "$as_me:$LINENO: checking if FriBidi support requested" >&5
+echo $ECHO_N "checking if FriBidi support requested... $ECHO_C" >&6; }
+
+
+# Check whether --with-fribidi-config was given.
+if test "${with_fribidi_config+set}" = set; then
+ withval=$with_fribidi_config;
+fi
+
+
+if test "$with_fribidi_config" = "no" -o "$with_fribidi_config" = "" ; then
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ FRIBIDI_CONFIG="no"
+elif test "$with_fribidi_config" = "yes" ; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ # Extract the first word of "fribidi-config", so it can be a program name with args.
+set dummy fribidi-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_FRIBIDI_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $FRIBIDI_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_FRIBIDI_CONFIG="$FRIBIDI_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_FRIBIDI_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_FRIBIDI_CONFIG" && ac_cv_path_FRIBIDI_CONFIG="no"
+ ;;
+esac
+fi
+FRIBIDI_CONFIG=$ac_cv_path_FRIBIDI_CONFIG
+if test -n "$FRIBIDI_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $FRIBIDI_CONFIG" >&5
+echo "${ECHO_T}$FRIBIDI_CONFIG" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+else
+ FRIBIDI_CONFIG=$with_fribidi_config
+fi
+
+if test "$FRIBIDI_CONFIG" = "no" ; then
+ FRIBIDI_ENABLED=
+ FRIBIDI_INC=
+ FRIBIDI_LIB=
+else
+ { echo "$as_me:$LINENO: result: yes, user supplied fribidi-config" >&5
+echo "${ECHO_T}yes, user supplied fribidi-config" >&6; }
+ FRIBIDI_ENABLED=-DUSE_FRIBIDI
+ FRIBIDI_LIB=`$FRIBIDI_CONFIG --libs`
+ FRIBIDI_INC=`$FRIBIDI_CONFIG --cflags`
+fi
+
+FRIBIDI_ENABLED=$FRIBIDI_ENABLED
+
+FRIBIDI_INC=$FRIBIDI_INC
+
+FRIBIDI_LIB=$FRIBIDI_LIB
+
+
+ALL_ENABLED="$FRIBIDI_ENABLED $ALL_ENABLED"
+ALL_INC="$FRIBIDI_INC $ALL_INC"
+ALL_LIB="$FRIBIDI_LIB $ALL_LIB"
+
+
{ echo "$as_me:$LINENO: checking for libxml2" >&5
echo $ECHO_N "checking for libxml2... $ECHO_C" >&6; }
@@ -13486,6 +13578,10 @@
LIBCURL_CONFIG!$LIBCURL_CONFIG$ac_delim
CURL_INC!$CURL_INC$ac_delim
CURL_LIB!$CURL_LIB$ac_delim
+FRIBIDI_CONFIG!$FRIBIDI_CONFIG$ac_delim
+FRIBIDI_ENABLED!$FRIBIDI_ENABLED$ac_delim
+FRIBIDI_INC!$FRIBIDI_INC$ac_delim
+FRIBIDI_LIB!$FRIBIDI_LIB$ac_delim
LIBXML2_CONFIG!$LIBXML2_CONFIG$ac_delim
XML2_INC!$XML2_INC$ac_delim
XML2_LIB!$XML2_LIB$ac_delim
@@ -13526,7 +13622,7 @@
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 70; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 74; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -13903,6 +13999,8 @@
echo "${ECHO_T} Proj.4 support: ${PROJ_ENABLED}" >&6; }
{ echo "$as_me:$LINENO: result: Libxml2 support: ${XML2_ENABLED}" >&5
echo "${ECHO_T} Libxml2 support: ${XML2_ENABLED}" >&6; }
+{ echo "$as_me:$LINENO: result: FriBidi support: ${FRIBIDI_ENABLED}" >&5
+echo "${ECHO_T} FriBidi support: ${FRIBIDI_ENABLED}" >&6; }
{ echo "$as_me:$LINENO: result: Curl support: ${CURL_ENABLED}" >&5
echo "${ECHO_T} Curl support: ${CURL_ENABLED}" >&6; }
{ echo "$as_me:$LINENO: result: FastCGI support: ${FASTCGI_ENABLED}" >&5
Modified: trunk/mapserver/configure.in
===================================================================
--- trunk/mapserver/configure.in 2008-03-14 12:28:06 UTC (rev 7456)
+++ trunk/mapserver/configure.in 2008-03-17 18:44:51 UTC (rev 7457)
@@ -1787,6 +1787,45 @@
ALL_LIB="$CURL_LIB $ALL_LIB"
+dnl ---------------------------------------------------------------------------
+dnl Try to find FriBidi if FriBidi support requested.
+dnl ---------------------------------------------------------------------------
+
+AC_MSG_CHECKING(if FriBidi support requested)
+
+AC_ARG_WITH(fribidi-config,
+[ --with-fribidi-config[[=ARG]] Include FriBidi Support (ARG=yes/path to
+ fribidi-config)],,)
+
+if test "$with_fribidi_config" = "no" -o "$with_fribidi_config" = "" ; then
+ AC_MSG_RESULT(no)
+ FRIBIDI_CONFIG="no"
+elif test "$with_fribidi_config" = "yes" ; then
+ AC_MSG_RESULT(yes)
+ AC_PATH_PROG(FRIBIDI_CONFIG, fribidi-config, no)
+else
+ FRIBIDI_CONFIG=$with_fribidi_config
+fi
+
+if test "$FRIBIDI_CONFIG" = "no" ; then
+ FRIBIDI_ENABLED=
+ FRIBIDI_INC=
+ FRIBIDI_LIB=
+else
+ AC_MSG_RESULT([yes, user supplied fribidi-config])
+ FRIBIDI_ENABLED=-DUSE_FRIBIDI
+ FRIBIDI_LIB=`$FRIBIDI_CONFIG --libs`
+ FRIBIDI_INC=`$FRIBIDI_CONFIG --cflags`
+fi
+
+AC_SUBST(FRIBIDI_ENABLED,$FRIBIDI_ENABLED)
+AC_SUBST(FRIBIDI_INC,$FRIBIDI_INC)
+AC_SUBST(FRIBIDI_LIB,$FRIBIDI_LIB)
+
+ALL_ENABLED="$FRIBIDI_ENABLED $ALL_ENABLED"
+ALL_INC="$FRIBIDI_INC $ALL_INC"
+ALL_LIB="$FRIBIDI_LIB $ALL_LIB"
+
dnl ---------------------------------------------------------------------
dnl Look for libxml2 if SOS Server requested
dnl ---------------------------------------------------------------------
@@ -2431,6 +2470,7 @@
AC_MSG_RESULT([ -------------- Support Libraries --------- ])
AC_MSG_RESULT([ Proj.4 support: ${PROJ_ENABLED}])
AC_MSG_RESULT([ Libxml2 support: ${XML2_ENABLED}])
+AC_MSG_RESULT([ FriBidi support: ${FRIBIDI_ENABLED}])
AC_MSG_RESULT([ Curl support: ${CURL_ENABLED}])
AC_MSG_RESULT([ FastCGI support: ${FASTCGI_ENABLED}])
AC_MSG_RESULT([ Threading support: ${THREAD_FLAG}])
Modified: trunk/mapserver/maperror.c
===================================================================
--- trunk/mapserver/maperror.c 2008-03-14 12:28:06 UTC (rev 7456)
+++ trunk/mapserver/maperror.c 2008-03-17 18:44:51 UTC (rev 7457)
@@ -505,6 +505,12 @@
#ifdef USE_GD_FT
strcat(version, " SUPPORTS=FREETYPE");
#endif
+#ifdef USE_ICONV
+ strcat(version, " SUPPORTS=ICONV");
+#endif
+#ifdef USE_FRIBIDI
+ strcat(version, " SUPPORTS=FRIBIDI");
+#endif
#ifdef USE_WMS_SVR
strcat(version, " SUPPORTS=WMS_SERVER");
#endif
Modified: trunk/mapserver/mapstring.c
===================================================================
--- trunk/mapserver/mapstring.c 2008-03-14 12:28:06 UTC (rev 7456)
+++ trunk/mapserver/mapstring.c 2008-03-17 18:44:51 UTC (rev 7457)
@@ -34,6 +34,11 @@
#include <ctype.h>
+#ifdef USE_FRIBIDI
+#include <fribidi/fribidi.h>
+#define MAX_STR_LEN 65000
+#endif
+
#ifdef USE_ICONV
#include <iconv.h>
#include <wchar.h>
@@ -1063,6 +1068,103 @@
/*
+** Use FRIBIDI to encode the string.
+** The return value must be freed by the caller.
+*/
+#ifdef USE_FRIBIDI
+char *msGetFriBidiEncodedString(const char *string, const char *encoding)
+{
+ FriBidiChar logical[MAX_STR_LEN];
+ FriBidiCharType base = FRIBIDI_TYPE_ON;
+ size_t len;
+
+#ifdef FRIBIDI_NO_CHARSETS
+ iconv_t to_ucs4, from_ucs4;
+#else
+ int to_char_set_num;
+ int from_char_set_num;
+#endif
+
+ len = strlen(string);
+
+#ifdef FRIBIDI_NO_CHARSETS
+ to_ucs4 = iconv_open ("WCHAR_T", encoding);
+ from_ucs4 = iconv_open ("UTF-8", "WCHAR_T");
+#else
+ to_char_set_num = fribidi_parse_charset ((char*)encoding);
+ from_char_set_num = fribidi_parse_charset ("UTF-8");
+#endif
+
+#ifdef FRIBIDI_NO_CHARSETS
+ if (to_ucs4 == (iconv_t) (-1) || from_ucs4 == (iconv_t) (-1))
+#else
+ if (!to_char_set_num || !from_char_set_num)
+#endif
+ {
+ msSetError(MS_IDENTERR, "Encoding not supported (%s).",
+ "msGetFriBidiEncodedString()", encoding);
+ return NULL;
+ }
+
+#ifdef FRIBIDI_NO_CHARSETS
+ {
+ char *st = string, *ust = (char *) logical;
+ int in_len = (int) len;
+ len = sizeof logical;
+ iconv (to_ucs4, &st, &in_len, &ust, (int *) &len);
+ len = (FriBidiChar *) ust - logical;
+ }
+#else
+ len = fribidi_charset_to_unicode (to_char_set_num, (char*)string, len, logical);
+#endif
+
+ {
+ FriBidiChar *visual;
+ char outstring[MAX_STR_LEN];
+ FriBidiStrIndex *ltov, *vtol;
+ FriBidiLevel *levels;
+ FriBidiStrIndex new_len;
+ fribidi_boolean log2vis;
+
+ visual = (FriBidiChar *) malloc (sizeof (FriBidiChar) * (len + 1));
+ ltov = NULL;
+ vtol = NULL;
+ levels = NULL;
+
+ /* Create a bidi string. */
+ log2vis = fribidi_log2vis (logical, len, &base,
+ /* output */
+ visual, ltov, vtol, levels);
+
+ if (!log2vis) {
+ msSetError(MS_IDENTERR, "Failed to create bidi string.",
+ "msGetFriBidiEncodedString()");
+ return NULL;
+ }
+
+ new_len = len;
+
+ /* Convert it to utf-8 for display. */
+#ifdef FRIBIDI_NO_CHARSETS
+ {
+ char *str = outstring, *ust = (char *) visual;
+ int in_len = len * sizeof visual[0];
+ new_len = sizeof outstring;
+ iconv (from_ucs4, &ust, &in_len, &str, (int *) &new_len);
+ *str = '\0';
+ new_len = str - outstring;
+ }
+#else
+ new_len =
+ fribidi_unicode_to_charset (from_char_set_num,
+ visual, len, outstring);
+#endif
+ return strdup(outstring);
+ }
+}
+#endif
+
+/*
** Simple charset converter. Converts string from specified encoding to UTF-8.
** The return value must be freed by the caller.
*/
@@ -1074,6 +1176,10 @@
char *outp, *out = NULL;
size_t len, bufsize, bufleft, status;
+#ifdef USE_FRIBIDI
+ if(fribidi_parse_charset ((char*)encoding))
+ return msGetFriBidiEncodedString(string, encoding);
+#endif
len = strlen(string);
if (len == 0 || (encoding && strcasecmp(encoding, "UTF-8")==0))
More information about the mapserver-commits
mailing list