summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-17 20:56:45 +0100
committerwm4 <wm4@nowhere>2012-11-20 18:00:15 +0100
commit80270218cb9bda57afbb739fa22f7eb2f3a556ff (patch)
tree9e38c23238ef01e7f8d71e8adf99674e3044148e /core
parentd23b620a89e88b0ec0d6a66c7f05c2e461579647 (diff)
downloadmpv-80270218cb9bda57afbb739fa22f7eb2f3a556ff.tar.bz2
mpv-80270218cb9bda57afbb739fa22f7eb2f3a556ff.tar.xz
osd: make the OSD and sub font more customizable
Make more aspects of the OSD font customizable. This also affects the font used for unstyled subtitles (such as SRT), or when using the --no-ass option. This adds back some customizability that was lost with commit 74e7a1 (osd: use libass for OSD rendering). Removed options: --ass-border-color --ass-color --font --subfont --subfont-text-scale Added options: --osd-color --osd-border --osd-back-color --osd-shadow-color --osd-font --osd-font-size --osd-border-size --osd-margin-x --osd-margin-y --osd-shadow-offset --osd-spacing --sub-scale The font size is now specified in pixels as it would be rendered on a window with a height of 720 pixels. OSD and subtitles are always scaled with the window height, so specifying or expecting an absolute font size doesn't make sense. Such scaled pixel units are used to specify font border etc. as well. (Note: the font size is directly passed to libass. How the fonts are actually rasterized is outside of our control, but in theory ASS font sizes map to "script" pixels and then are scaled to screen size.) The default settings should be about the same, with slight difference due to rounding to the new scales. The OSD and subtitle fonts are not separately configurable. It has limited use and would double the number of newly added options, which would be more confusing than helpful. It could be easily added later, should the need arise. Other small details that change: - ASS_Style.Encoding is not set to -1 for subs anymore (assuming subs use VSFilter direction in -no-ass mode too) - use a different WrapStyle for OSD - ASS forced styles are not applied to OSD
Diffstat (limited to 'core')
-rw-r--r--core/cfg-mplayer.h10
-rw-r--r--core/command.c27
-rw-r--r--core/defaultopts.c2
-rw-r--r--core/mplayer.c2
-rw-r--r--core/options.h5
5 files changed, 10 insertions, 36 deletions
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 531b3700ac..499ba3f1e3 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -508,12 +508,9 @@ const m_option_t common_opts[] = {
{"sub-no-text-pp", &sub_no_text_pp, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"autosub-match", &sub_match_fuzziness, CONF_TYPE_CHOICE, 0,
M_CHOICES(({"exact", 0}, {"fuzzy", 1}, {"all", 2}))},
- {"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"subfont", &sub_font_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"sub-pos", &sub_pos, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
- {"subfont-text-scale", &text_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
OPT_MAKE_FLAGS("ass", ass_enabled, 0),
- OPT_FLOATRANGE("ass-font-scale", ass_font_scale, 0, 0, 100),
+ OPT_FLOATRANGE("sub-scale", sub_scale, 0, 0, 100),
OPT_FLOATRANGE("ass-line-spacing", ass_line_spacing, 0, -1000, 1000),
OPT_INTRANGE("ass-top-margin", ass_top_margin, 0, 0, 2000),
OPT_INTRANGE("ass-bottom-margin", ass_bottom_margin, 0, 0, 2000),
@@ -521,12 +518,13 @@ const m_option_t common_opts[] = {
OPT_MAKE_FLAGS("ass-vsfilter-aspect-compat", ass_vsfilter_aspect_compat, 0),
OPT_MAKE_FLAGS("embeddedfonts", use_embedded_fonts, 0),
OPT_STRINGLIST("ass-force-style", ass_force_style_list, 0),
- OPT_STRING("ass-color", ass_color, 0),
- OPT_STRING("ass-border-color", ass_border_color, 0),
OPT_STRING("ass-styles", ass_styles_file, 0),
OPT_INTRANGE("ass-hinting", ass_hinting, 0, 0, 7),
OPT_CHOICE("ass-style-override", ass_style_override, 0,
({"no", 0}, {"yes", 1})),
+ OPT_GENERAL("osd", osd_style, M_OPT_PREFIXED,
+ .type = &m_option_type_subconfig_struct,
+ .priv = (void*)&osd_style_conf),
{NULL, NULL, 0, 0, 0, 0, NULL}
};
diff --git a/core/command.c b/core/command.c
index 2346a9e821..a7e7153c34 100644
--- a/core/command.c
+++ b/core/command.c
@@ -1224,7 +1224,7 @@ static int property_sub_helper(m_option_t *prop, int action, void *arg,
if (!mpctx->sh_video)
return M_PROPERTY_UNAVAILABLE;
if (action == M_PROPERTY_SET)
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ osd_subs_changed(mpctx->osd);
return mp_property_generic_option(prop, action, arg, mpctx);
}
@@ -1299,28 +1299,6 @@ static int mp_property_sub_forced_only(m_option_t *prop, int action,
return mp_property_generic_option(prop, action, arg, mpctx);
}
-/// Subtitle scale (RW)
-static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
- MPContext *mpctx)
-{
- struct MPOpts *opts = &mpctx->opts;
-
- float *pscale = opts->ass_enabled
- ? &opts->ass_font_scale : &text_font_scale_factor;
-
- switch (action) {
- case M_PROPERTY_SET:
- *pscale = *(float *) arg;
- vo_osd_changed(OSDTYPE_SUBTITLE);
- vo_osd_changed(OSDTYPE_OSD);
- return M_PROPERTY_OK;
- case M_PROPERTY_GET:
- *(float *)arg = *pscale;
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
-}
-
#ifdef CONFIG_TV
@@ -1486,8 +1464,7 @@ static const m_option_t mp_properties[] = {
{ "sub-visibility", mp_property_sub_visibility, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
M_OPTION_PROPERTY_CUSTOM("sub-forced-only", mp_property_sub_forced_only),
- { "sub-scale", mp_property_sub_scale, CONF_TYPE_FLOAT,
- M_OPT_RANGE, 0, 100, NULL },
+ M_OPTION_PROPERTY_CUSTOM("sub-scale", property_sub_helper),
#ifdef CONFIG_ASS
M_OPTION_PROPERTY_CUSTOM("ass-use-margins", property_sub_helper),
M_OPTION_PROPERTY_CUSTOM("ass-vsfilter-aspect-compat", property_sub_helper),
diff --git a/core/defaultopts.c b/core/defaultopts.c
index 16fda006c8..1c179a74a1 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -55,7 +55,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
#ifdef CONFIG_ASS
.ass_enabled = 1,
#endif
- .ass_font_scale = 1,
+ .sub_scale = 1,
.ass_vsfilter_aspect_compat = 1,
.ass_style_override = 1,
.use_embedded_fonts = 1,
diff --git a/core/mplayer.c b/core/mplayer.c
index 223774a711..6ad6365850 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3740,7 +3740,7 @@ static void add_subtitle_fonts_from_sources(struct MPContext *mpctx)
assert(!mpctx->osd->ass_renderer);
mpctx->osd->ass_renderer = ass_renderer_init(mpctx->osd->ass_library);
if (mpctx->osd->ass_renderer)
- mp_ass_configure_fonts(mpctx->osd->ass_renderer);
+ mp_ass_configure_fonts(mpctx->osd->ass_renderer, mpctx->opts.osd_style);
#endif
}
diff --git a/core/options.h b/core/options.h
index 50f5d10bbf..3f916310b6 100644
--- a/core/options.h
+++ b/core/options.h
@@ -110,8 +110,9 @@ typedef struct MPOpts {
char **sub_name;
char **sub_paths;
int sub_auto;
+ struct osd_style_opts *osd_style;
+ float sub_scale;
int ass_enabled;
- float ass_font_scale;
float ass_line_spacing;
int ass_top_margin;
int ass_bottom_margin;
@@ -119,8 +120,6 @@ typedef struct MPOpts {
int ass_vsfilter_aspect_compat;
int use_embedded_fonts;
char **ass_force_style_list;
- char *ass_color;
- char *ass_border_color;
char *ass_styles_file;
int ass_style_override;
int ass_hinting;