changeset 36658:f8d0a552f7a5

Relocate mplayerLoadFont() code. Add a mplayer() instruction MPLAYER_LOAD_FONT and make it part of this function.
author ib
date Sun, 26 Jan 2014 17:16:29 +0000
parents 85ae74e2e537
children f41b65ac7e81
files gui/dialog/fileselect.c gui/interface.c gui/interface.h
diffstat 3 files changed, 37 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/gui/dialog/fileselect.c	Sun Jan 26 17:05:33 2014 +0000
+++ b/gui/dialog/fileselect.c	Sun Jan 26 17:16:29 2014 +0000
@@ -507,7 +507,7 @@
 
     case FILESELECT_FONT:
         setddup(&font_name, fsSelectedDirectory, fsSelectedFile);
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
 
         if (Preferences)
             gtk_entry_set_text(GTK_ENTRY(prEFontName), font_name);
--- a/gui/interface.c	Sun Jan 26 17:05:33 2014 +0000
+++ b/gui/interface.c	Sun Jan 26 17:16:29 2014 +0000
@@ -959,38 +959,66 @@
 
     case MPLAYER_SET_FONT_FACTOR:
         font_factor = value;
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_OUTLINE:
         subtitle_font_thickness = 8.0 * value / 100.0;   // transform 0..100 to 0..8
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_BLUR:
         subtitle_font_radius = 8.0 * value / 100.0;      // transform 0..100 to 0..8
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_TEXTSCALE:
         text_font_scale_factor = value;
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_OSDSCALE:
         osd_font_scale_factor = value;
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_ENCODING:
         nfree(subtitle_font_encoding);
         subtitle_font_encoding = gstrdup((char *)data);
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
         break;
 
     case MPLAYER_SET_FONT_AUTOSCALE:
         subtitle_autoscale = (int)value;
-        mplayerLoadFont();
+        mplayer(MPLAYER_LOAD_FONT, 0, 0);
+        break;
+
+    case MPLAYER_LOAD_FONT:
+#ifdef CONFIG_FREETYPE
+        set_fontconfig();
+
+        force_load_font = 1;
+#else
+        free_font_desc(vo_font);
+
+        if (font_name) {
+            vo_font = read_font_desc(font_name, font_factor, 0);
+
+            if (!vo_font)
+                gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
+        } else {
+            char *fname = get_path("font/font.desc");
+
+            setdup(&font_name, fname);
+            free(fname);
+            vo_font = read_font_desc(font_name, font_factor, 0);
+
+            if (!vo_font) {
+                setdup(&font_name, MPLAYER_DATADIR "/font/font.desc");
+                vo_font = read_font_desc(font_name, font_factor, 0);
+            }
+        }
+#endif
         break;
 
     case MPLAYER_SET_SUB_ENCODING:
@@ -1080,35 +1108,6 @@
     }
 }
 
-void mplayerLoadFont(void)
-{
-#ifdef CONFIG_FREETYPE
-    set_fontconfig();
-
-    force_load_font = 1;
-#else
-    free_font_desc(vo_font);
-
-    if (font_name) {
-        vo_font = read_font_desc(font_name, font_factor, 0);
-
-        if (!vo_font)
-            gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadFont, font_name);
-    } else {
-        char *fname = get_path("font/font.desc");
-
-        setdup(&font_name, fname);
-        free(fname);
-        vo_font = read_font_desc(font_name, font_factor, 0);
-
-        if (!vo_font) {
-            setdup(&font_name, MPLAYER_DATADIR "/font/font.desc");
-            vo_font = read_font_desc(font_name, font_factor, 0);
-        }
-    }
-#endif
-}
-
 void mplayerLoadSubtitle(const char *name)
 {
     if (guiInfo.Playing == GUI_STOP)
--- a/gui/interface.h	Sun Jan 26 17:05:33 2014 +0000
+++ b/gui/interface.h	Sun Jan 26 17:16:29 2014 +0000
@@ -76,6 +76,7 @@
 /// mplayer() instructions
 enum {
     MPLAYER_EXIT_GUI,
+    MPLAYER_LOAD_FONT,
     MPLAYER_SET_AUTO_QUALITY,
     MPLAYER_SET_BRIGHTNESS,
     MPLAYER_SET_CONTRAST,
@@ -150,7 +151,6 @@
 /// @name GUI -> MPlayer
 //@{
 void mplayer(int what, float value, void *data);
-void mplayerLoadFont(void);
 void mplayerLoadSubtitle(const char *name);
 void gmp_msg(int mod, int lev, const char *format, ...);
 //@}