>From 3fef7bc66cccc85e6c7c638f2c603008d807da79 Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Sun, 9 Oct 2011 16:44:16 +0900 Subject: [PATCH 38/41] Add OS/2 support to freetype module --- modules/text_renderer/freetype.c | 39 ++++++++++++++++++++++++++----------- 1 files changed, 27 insertions(+), 12 deletions(-) diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c index 069e01d..8406d1f 100644 --- a/modules/text_renderer/freetype.c +++ b/modules/text_renderer/freetype.c @@ -51,6 +51,9 @@ #elif defined( WIN32 ) # define DEFAULT_FONT_FILE "arial.ttf" /* Default path font found at run-time */ # define DEFAULT_FAMILY "Arial" +#elif defined( __OS2__ ) +# define DEFAULT_FONT_FILE "/psfonts/tnrwt_k.ttf" +# define DEFAULT_FAMILY "Times New Roman WT K" #elif defined( HAVE_MAEMO ) # define DEFAULT_FONT_FILE "/usr/share/fonts/nokia/nosnb.ttf" # define DEFAULT_FAMILY "Nokia Sans Bold" @@ -92,6 +95,18 @@ #include +#ifdef __OS2__ +# define UCHAR uint16_t +# define FREETYPE_TO_UCS "UCS-2LE" +#else +# define UCHAR uint32_t +# if defined(WORDS_BIGENDIAN) +# define FREETYPE_TO_UCS "UCS-4BE" +# else +# define FREETYPE_TO_UCS "UCS-4LE" +# endif +#endif + /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -434,6 +449,10 @@ static void FontConfig_BuildCache( filter_t *p_filter ) mtime_t t1, t2; t1 = mdate(); +#ifdef __OS2__ + FcInit(); +#endif + #ifdef WIN32 dialog_progress_bar_t *p_dialog = NULL; FcConfig *fcConfig = FcInitLoadConfig(); @@ -1388,7 +1407,7 @@ static text_style_t *GetStyleFromFontStack( filter_sys_t *p_sys, } static unsigned SetupText( filter_t *p_filter, - uint32_t *psz_text_out, + UCHAR *psz_text_out, text_style_t **pp_styles, uint32_t *pi_k_dates, @@ -1399,15 +1418,11 @@ static unsigned SetupText( filter_t *p_filter, size_t i_string_length; size_t i_string_bytes; -#if defined(WORDS_BIGENDIAN) - uint32_t *psz_tmp = ToCharset( "UCS-4BE", psz_text_in, &i_string_bytes ); -#else - uint32_t *psz_tmp = ToCharset( "UCS-4LE", psz_text_in, &i_string_bytes ); -#endif + UCHAR *psz_tmp = ToCharset( FREETYPE_TO_UCS, psz_text_in, &i_string_bytes ); if( psz_tmp ) { memcpy( psz_text_out, psz_tmp, i_string_bytes ); - i_string_length = i_string_bytes / 4; + i_string_length = i_string_bytes / sizeof( *psz_tmp ); free( psz_tmp ); } else @@ -1434,7 +1449,7 @@ static unsigned SetupText( filter_t *p_filter, } static int ProcessNodes( filter_t *p_filter, - uint32_t *psz_text, + UCHAR *psz_text, text_style_t **pp_styles, uint32_t *pi_k_dates, int *pi_len, @@ -1831,13 +1846,13 @@ static int ProcessLines( filter_t *p_filter, FT_BBox *p_bbox, int *pi_max_face_height, - uint32_t *psz_text, + UCHAR *psz_text, text_style_t **pp_styles, uint32_t *pi_k_dates, int i_len ) { filter_sys_t *p_sys = p_filter->p_sys; - uint32_t *p_fribidi_string = NULL; + UCHAR *p_fribidi_string = NULL; text_style_t **pp_fribidi_styles = NULL; int *p_new_positions = NULL; @@ -2033,7 +2048,7 @@ static int ProcessLines( filter_t *p_filter, while( i_part_length > 0 ) { const text_style_t *p_glyph_style = pp_styles[i_index]; - uint32_t character = psz_text[i_index]; + UCHAR character = psz_text[i_index]; int i_glyph_index = FT_Get_Char_Index( p_current_face, character ); /* Get kerning vector */ @@ -2266,7 +2281,7 @@ static int RenderCommon( filter_t *p_filter, subpicture_region_t *p_region_out, const size_t i_text_max = strlen( b_html ? p_region_in->psz_html : p_region_in->psz_text ); - uint32_t *psz_text = calloc( i_text_max, sizeof( *psz_text ) ); + UCHAR *psz_text = calloc( i_text_max, sizeof( *psz_text ) ); text_style_t **pp_styles = calloc( i_text_max, sizeof( *pp_styles ) ); if( !psz_text || !pp_styles ) { -- 1.7.3.2