changeset 36650:8b2c68d6fd89

Enable specifying a font file in the GUI preferences. This has been broken since the introduction of Fontconfig. Since Fontconfig is selecting fonts by font patterns and the GUI does so by selecting a font file, it is necessary to temporarily disable fontconfig font handling if there is a directory separator character found in the name (or pattern) of the font to be used, i.e. assume the font name to be a pattern if and only if it doesn't contain a directory separator character. Thus set option 'fontconfig' depending on font_name. Set it in guiInit() for the font possibly given in a configuration file or on the command line, and set it in mplayerLoadFont() whenever it is affected by GUI preferences settings. (Although the font selection dialog only allows files to be selected, it is possible to simply enter a fontconfig font pattern in the preferences' text entry field - or to enter it directly into the GUI configuration file or to specify on the command line, both of which always is possible.)
author ib
date Sun, 26 Jan 2014 16:40:49 +0000
parents 780f1cf49497
children 64f9837de3a5
files gui/interface.c
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gui/interface.c	Sun Jan 26 16:20:48 2014 +0000
+++ b/gui/interface.c	Sun Jan 26 16:40:49 2014 +0000
@@ -71,6 +71,15 @@
 };
 
 static int guiInitialized;
+static int orig_fontconfig;
+
+/**
+ * @brief Set option 'fontconfig' depending on #font_name.
+ */
+static void set_fontconfig(void)
+{
+    font_fontconfig = (font_name && strchr(font_name, '/') ? -1 : orig_fontconfig);
+}
 
 /* MPlayer -> GUI */
 
@@ -208,6 +217,9 @@
     if (subdata)
         setdup(&guiInfo.SubtitleFilename, subdata->filename);
 
+    orig_fontconfig = font_fontconfig;
+    set_fontconfig();
+
     guiInitialized = True;
 }
 
@@ -1071,6 +1083,8 @@
 void mplayerLoadFont(void)
 {
 #ifdef CONFIG_FREETYPE
+    set_fontconfig();
+
     load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
 #else
     if (vo_font) {