[MPlayer-cvslog] r28276 - in trunk/libvo: font_load.h font_load_ft.c

eugeni subversion at mplayerhq.hu
Tue Jan 6 17:44:48 CET 2009


Author: eugeni
Date: Tue Jan  6 17:44:47 2009
New Revision: 28276

Log:
Support loading font faces other then the first one in a font file.

With -fontconfig, it is possible to select a face with index higher than
0 in a multi-face font file. Currently, with the old rendering code,
this information is lost and the first face is loaded. With this change,
index supplied by fontconfig is used for font loading.

Patch by Adrian Stutz, adrian sttz ch.

Modified:
   trunk/libvo/font_load.h
   trunk/libvo/font_load_ft.c

Modified: trunk/libvo/font_load.h
==============================================================================
--- trunk/libvo/font_load.h	Mon Jan  5 23:55:58 2009	(r28275)
+++ trunk/libvo/font_load.h	Tue Jan  6 17:44:47 2009	(r28276)
@@ -79,7 +79,7 @@ extern int force_load_font;
 int init_freetype(void);
 int done_freetype(void);
 
-font_desc_t* read_font_desc_ft(const char* fname,int movie_width, int movie_height, float font_scale_factor);
+font_desc_t* read_font_desc_ft(const char* fname,int face_index,int movie_width, int movie_height, float font_scale_factor);
 void free_font_desc(font_desc_t *desc);
 
 void render_one_glyph(font_desc_t *desc, int c);

Modified: trunk/libvo/font_load_ft.c
==============================================================================
--- trunk/libvo/font_load_ft.c	Mon Jan  5 23:55:58 2009	(r28275)
+++ trunk/libvo/font_load_ft.c	Tue Jan  6 17:44:47 2009	(r28276)
@@ -893,11 +893,11 @@ void free_font_desc(font_desc_t *desc)
     free(desc);
 }
 
-static int load_sub_face(const char *name, FT_Face *face)
+static int load_sub_face(const char *name, int face_index, FT_Face *face)
 {
     int err = -1;
     
-    if (name) err = FT_New_Face(library, name, 0, face);
+    if (name) err = FT_New_Face(library, name, face_index, face);
 
     if (err) {
 	char *font_file = get_path("subfont.ttf");
@@ -940,7 +940,7 @@ int kerning(font_desc_t *desc, int prevc
     return f266ToInt(kern.x);
 }
 
-font_desc_t* read_font_desc_ft(const char *fname, int movie_width, int movie_height, float font_scale_factor)
+font_desc_t* read_font_desc_ft(const char *fname, int face_index, int movie_width, int movie_height, float font_scale_factor)
 {
     font_desc_t *desc = NULL;
 
@@ -1002,7 +1002,7 @@ font_desc_t* read_font_desc_ft(const cha
 //    t=GetTimer();
 
     /* generate the subtitle font */
-    err = load_sub_face(fname, &face);
+    err = load_sub_face(fname, face_index, &face);
     if (err) {
 	mp_msg(MSGT_OSD, MSGL_WARN, MSGTR_LIBVO_FONT_LOAD_FT_SubFaceFailed);
 	goto gen_osd;
@@ -1128,6 +1128,7 @@ void load_font_ft(int width, int height,
     FcPattern *fc_pattern;
     FcPattern *fc_pattern2;
     FcChar8 *s;
+    int face_index;
     FcBool scalable;
 #endif
     font_desc_t *vo_font = *fontp;
@@ -1163,10 +1164,11 @@ void load_font_ft(int width, int height,
 	}
 	// s doesn't need to be freed according to fontconfig docs
 	FcPatternGetString(fc_pattern, FC_FILE, 0, &s);
-	*fontp=read_font_desc_ft(s, width, height, font_scale_factor);
+	FcPatternGetInteger(fc_pattern, FC_INDEX, 0, &face_index);
+	*fontp=read_font_desc_ft(s, face_index, width, height, font_scale_factor);
 	FcPatternDestroy(fc_pattern);
     }
     else
 #endif
-    *fontp=read_font_desc_ft(font_name, width, height, font_scale_factor);
+    *fontp=read_font_desc_ft(font_name, 0, width, height, font_scale_factor);
 }



More information about the MPlayer-cvslog mailing list