[vlc-devel] [PATCH 08/11] Add OS/2 support to freetype module

KO Myung-Hun komh at chollian.net
Sun Nov 6 10:58:27 CET 2011


---
 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 7963f5c..354eb36 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 <assert.h>
 
+#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();
@@ -1413,7 +1432,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,
 
@@ -1424,15 +1443,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
@@ -1459,7 +1474,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,
@@ -1856,13 +1871,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;
 
@@ -2058,7 +2073,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 */
@@ -2291,7 +2306,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



More information about the vlc-devel mailing list