diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-12-08 12:14:32 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-12-08 12:14:32 +0000 |
commit | e7d9078afcad18cae14e4653b1e945926471fbac (patch) | |
tree | bcc99f41030e05c9110aeb24e63aa27dbf76b188 /libvo | |
parent | a6bd35c9a2d7618b5d9eeb17751e1fd8fddf04bf (diff) | |
download | mpv-e7d9078afcad18cae14e4653b1e945926471fbac.tar.bz2 mpv-e7d9078afcad18cae14e4653b1e945926471fbac.tar.xz |
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz@gmx.net>, but slightly reworked
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11581 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/font_load_ft.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libvo/font_load_ft.c b/libvo/font_load_ft.c index 141baeddfc..3279d98361 100644 --- a/libvo/font_load_ft.c +++ b/libvo/font_load_ft.c @@ -24,6 +24,10 @@ #include FT_FREETYPE_H #include FT_GLYPH_H +#ifdef HAVE_FONTCONFIG +#include <fontconfig/fontconfig.h> +#endif + #include "../bswap.h" #include "font_load.h" #include "mp_msg.h" @@ -1113,6 +1117,11 @@ int done_freetype() void load_font_ft(int width, int height) { +#ifdef HAVE_FONTCONFIG + FcPattern *fc_pattern; + FcChar8 *s; + FcBool scalable; +#endif vo_image_width = width; vo_image_height = height; @@ -1122,6 +1131,30 @@ void load_font_ft(int width, int height) if (vo_font) free_font_desc(vo_font); #ifdef USE_OSD +#ifdef HAVE_FONTCONFIG + if (font_fontconfig) + { + if (!font_name) + font_name = "sans-serif"; + FcInit(); + fc_pattern = FcNameParse(font_name); + FcConfigSubstitute(0, fc_pattern, FcMatchPattern); + FcDefaultSubstitute(fc_pattern); + fc_pattern = FcFontMatch(0, fc_pattern, 0); + FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable); + if (scalable != FcTrue) { + fc_pattern = FcNameParse("sans-serif"); + FcConfigSubstitute(0, fc_pattern, FcMatchPattern); + FcDefaultSubstitute(fc_pattern); + fc_pattern = FcFontMatch(0, fc_pattern, 0); + } + // s doesn't need to be freed according to fontconfig docs + FcPatternGetString(fc_pattern, FC_FILE, 0, &s); + vo_font=read_font_desc_ft(s, width, height); + free(fc_pattern); + } + else +#endif vo_font=read_font_desc_ft(font_name, width, height); #endif } |