configure.ac, modules/misc/freetype.c:

  * Bidi support in the freetype module through fribidi
parent 8fb55fe0
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.91 2003/10/23 17:04:39 sam Exp $
dnl $Id: configure.ac,v 1.92 2003/10/23 23:00:37 sigmunau Exp $
AC_INIT(vlc,0.6.3-cvs)
......@@ -2285,6 +2285,15 @@ then
FREETYPE_PATH="${with_freetype_config_path}:${PATH}"
fi ])
AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no, ${FREETYPE_PATH})
FRIBIDI_PATH="${PATH}"
AC_ARG_WITH(fribidi-config-path,
[ --with-fribidi-config-path=PATH fribidi-config path (default search in \$PATH)],
[ if test "${with_fribidi_config_path}" != "no"
then
FRIBIDI_PATH="${with_fribidi_config_path}:${PATH}"
fi ])
AC_PATH_PROG(FRIBIDI_CONFIG, fribidi-config, no, ${FRIBIDI_PATH})
if test "${FREETYPE_CONFIG}" != "no"
then
......@@ -2300,6 +2309,11 @@ then
from http://www.freetype.org/, or configure with --disable-freetype. Have a nice day.
])
fi
if test "${FRIBIDI_CONFIG}" != "no"
then
AX_ADD_CFLAGS([freetype], [`${FRIBIDI_CONFIG} --cflags` -DHAVE_FRIBIDI])
AX_ADD_LDFLAGS([freetype], [`${FRIBIDI_CONFIG} --libs`])
fi
fi
dnl
......
......@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.24 2003/10/01 22:44:58 hartman Exp $
* $Id: freetype.c,v 1.25 2003/10/23 23:00:37 sigmunau Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
......@@ -44,6 +44,13 @@
#define DEFAULT_FONT ""
#endif
#if defined(HAVE_ICONV)
#include <iconv.h>
#endif
#if defined(HAVE_FRIBIDI)
#include <fribidi/fribidi.h>
#endif
typedef struct line_desc_t line_desc_t;
/*****************************************************************************
......@@ -636,9 +643,12 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
int i_vmargin, mtime_t i_start, mtime_t i_stop )
{
subpicture_sys_t *p_string;
int i, i_pen_y, i_pen_x, i_error, i_glyph_index, i_previous, i_char;
int i, i_pen_y, i_pen_x, i_error, i_glyph_index, i_previous;
subpicture_t *p_subpic;
line_desc_t *p_line, *p_next;
uint32_t *p_unicode_string, i_char;
int i_string_length;
iconv_t iconv_handle;
FT_BBox line;
FT_BBox glyph_size;
......@@ -696,6 +706,52 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
p_string->p_lines = 0;
p_string->psz_text = strdup( psz_string );
#if defined(HAVE_ICONV)
p_unicode_string = malloc( ( strlen(psz_string) + 1 ) * sizeof(uint32_t) );
if( p_unicode_string == NULL )
{
msg_Err( p_vout, "Out of memory" );
goto error;
}
iconv_handle = iconv_open( "UCS-4LE", "UTF-8" );
if( iconv_handle == (iconv_t)-1 )
{
msg_Warn( p_vout, "Unable to do convertion" );
goto error;
}
{
char *p_in_buffer;
uint32_t *p_out_buffer;
int i_in_bytes, i_out_bytes, i_out_bytes_left, i_ret;
i_in_bytes = strlen( psz_string );
i_out_bytes = i_in_bytes * sizeof( uint32_t );
i_out_bytes_left = i_out_bytes;
p_in_buffer = psz_string;
p_out_buffer = p_unicode_string;
i_ret = iconv( iconv_handle, &p_in_buffer, &i_in_bytes, (char**)&p_out_buffer, &i_out_bytes_left );
if( i_in_bytes )
{
msg_Warn( p_vout, "Failed to convert string to unicode (%s), bytes left %d", strerror(errno), i_in_bytes );
goto error;
}
*p_out_buffer = 0;
i_string_length = ( i_out_bytes - i_out_bytes_left ) / sizeof(uint32_t);
}
#if defined(HAVE_FRIBIDI)
{
uint32_t *p_fribidi_string;
FriBidiCharType base_dir = FRIBIDI_TYPE_ON;
p_fribidi_string = malloc( ( i_string_length + 1 ) * sizeof(uint32_t) );
fribidi_log2vis( p_unicode_string, i_string_length, &base_dir,
p_fribidi_string, NULL, NULL, NULL );
free( p_unicode_string );
p_unicode_string = p_fribidi_string;
p_fribidi_string[ i_string_length ] = 0;
}
#endif
#endif
/* Calculate relative glyph positions and a bounding box for the
* entire string */
p_line = NewLine( psz_string );
......@@ -713,10 +769,11 @@ static int AddText ( vout_thread_t *p_vout, byte_t *psz_string,
#define face p_vout->p_text_renderer_data->p_face
#define glyph face->glyph
while( *psz_string )
while( *p_unicode_string )
{
i_char = GetUnicodeCharFromUTF8( &psz_string );
// i_char = GetUnicodeCharFromUTF8( &psz_string );
i_char = *p_unicode_string++;
msg_Dbg( p_vout, "got char %d, '%c'", i_char, (char)i_char );
if ( i_char == '\r' ) /* ignore CR chars wherever they may be */
{
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment