Adding FriBidi support.

This commit is contained in:
William Kendrick 2008-12-04 00:14:02 +00:00
parent d9068fe797
commit 05077e6907
3 changed files with 52 additions and 6 deletions

View file

@ -4,7 +4,7 @@
# bill@newbreedsoftware.com
# http://www.tuxpaint.org/
# June 14, 2002 - July 7, 2008
# June 14, 2002 - December 3, 2008
# The version number, for release:
@ -74,10 +74,12 @@ PAPER_LIB:=$(call linktest,-lpaper,)
PNG:=$(call linktest,-lpng,)
PNG:=$(if $(PNG),$(PNG),$(call linktest,-lpng12,))
windows_ARCH_LINKS:=-lintl $(PNG) -lwinspool -lshlwapi
osx_ARCH_LINKS:=$(PAPER_LIB)
FRIBIDI_LIB:=-lfribidi
windows_ARCH_LINKS:=-lintl $(PNG) -lwinspool -lshlwapi $(FRIBIDI_LIB)
osx_ARCH_LINKS:=$(PAPER_LIB) $(FRIBIDI_LIB)
beos_ARCH_LINKS:="-lintl $(PNG) -lz -lbe -liconv"
linux_ARCH_LINKS:=$(PAPER_LIB)
linux_ARCH_LINKS:=$(PAPER_LIB) $(FRIBIDI_LIB)
ARCH_LINKS:=$($(OS)_ARCH_LINKS)
windows_ARCH_HEADERS:=src/win32_print.h

View file

@ -8,7 +8,7 @@ http://www.tuxpaint.org/
$Id$
2008.December.1 (0.9.21)
2008.December.3 (0.9.21)
* New Starters:
-------------
* Silver Frame
@ -91,6 +91,10 @@ $Id$
* White always appears as the first color in the "New" dialog,
regardless of its position (or even existence) in the color palette.
* Text tool uses FriBidi to determine when right-to-left characters have
been typed (e.g., Hebrew) so that they are drawn in the right direction.
(Mixing RtoL and LtoR works (e.g., Hebrew with numerals))
* New localizations:
------------------
* Shuswap (Secwepemctín) translation

View file

@ -963,6 +963,19 @@ char *papersize = NULL;
#endif
#if 1 /* FIXME: ifdef for platforms that lack fribidi? */
#include <fribidi/fribidi.h>
#if !defined(FRIBIDI_H)
#error "---------------------------------------------------"
#error "If you installed libfribidi from a package, be sure"
#error "to get the development package, as well!"
#error "(eg., 'libfribidi-dev')"
#error "---------------------------------------------------"
#endif
#else
/* FIXME: define a noop function */
#endif
enum
{
UNDO_STARTER_NONE,
@ -15479,7 +15492,34 @@ static void do_render_cur_text(int do_blit)
if (texttool_len > 0)
{
str = uppercase_w(texttool_str);
#ifdef FRIBIDI_H
FriBidiCharType baseDir = FRIBIDI_TYPE_LTR;
FriBidiChar *unicodeIn, *unicodeOut;
unsigned int i;
unicodeIn = (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1));
unicodeOut = (FriBidiChar *) malloc(sizeof(FriBidiChar) * (texttool_len + 1));
str = (wchar_t *) malloc(sizeof(wchar_t) * (texttool_len + 1));
for (i = 0; i < texttool_len; i++)
unicodeIn[i] = (FriBidiChar) texttool_str[i];
fribidi_log2vis(unicodeIn, texttool_len, &baseDir, unicodeOut, 0, 0, 0);
/* FIXME: If we determine that some new text was RtoL, we should
reposition the text */
for (i = 0; i < texttool_len; i++)
str[i] = (long) unicodeOut[i];
str[texttool_len] = L'\0';
free(unicodeIn);
free(unicodeOut);
#else
str = uppercase_w(texttool_str);
#endif
tmp_surf = render_text_w(getfonthandle(cur_font), str, color);