[MPlayer-cvslog] r36746 - trunk/gui/interface.c

ib subversion at mplayerhq.hu
Sun Jan 26 17:40:49 CET 2014

Author: ib
Date: Sun Jan 26 17:40:49 2014
New Revision: 36746

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.)


Modified: trunk/gui/interface.c
--- trunk/gui/interface.c	Sun Jan 26 17:20:48 2014	(r36745)
+++ trunk/gui/interface.c	Sun Jan 26 17:40:49 2014	(r36746)
@@ -71,6 +71,15 @@ guiInterface_t guiInfo = {
 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 @@ void guiInit(void)
     if (subdata)
         setdup(&guiInfo.SubtitleFilename, subdata->filename);
+    orig_fontconfig = font_fontconfig;
+    set_fontconfig();
     guiInitialized = True;
@@ -1071,6 +1083,8 @@ void mplayer(int what, float value, void
 void mplayerLoadFont(void)
+    set_fontconfig();
     load_font_ft(vo_image_width, vo_image_height, &vo_font, font_name, osd_font_scale_factor);
     if (vo_font) {

More information about the MPlayer-cvslog mailing list