summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/changes.rst1
-rw-r--r--DOCS/man/en/options.rst116
-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
-rw-r--r--sub/ass_mp.c76
-rw-r--r--sub/ass_mp.h14
-rw-r--r--sub/osd_libass.c46
-rw-r--r--sub/sub.c45
-rw-r--r--sub/sub.h23
12 files changed, 232 insertions, 135 deletions
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst
index 8bd81c1832..2f012f7b1b 100644
--- a/DOCS/man/en/changes.rst
+++ b/DOCS/man/en/changes.rst
@@ -109,6 +109,7 @@ Command line switches
-endpos --length
--cursor-autohide-delay --cursor-autohide
-sub-fuzziness --autosub-match
+ -subfont-text-scale --sub-scale
=================================== ===================================
input.conf and slave commands
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 44462ec863..3782dd2d31 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -118,20 +118,10 @@
text subtitles only, because ASS subtitles include their own styling
information.
---ass-border-color=<value>
- Sets the border (outline) color for text subtitles. The color format is
- RRGGBBAA.
-
--ass-bottom-margin=<value>
Adds a black band at the bottom of the frame. The SSA/ASS renderer can
place subtitles there (with ``--ass-use-margins``).
---ass-color=<value>
- Sets the color for text subtitles. The color format is RRGGBBAA.
-
---ass-font-scale=<value>
- Set the scale coefficient to be used for fonts in the SSA/ASS renderer.
-
--ass-force-style=<[Style.]Param=Value[,...]>
Override some style or script info parameters.
@@ -551,19 +541,6 @@
--flip
Flip image upside-down.
---font=<pattern-or-filename>
- Specify font to use for OSD and for subtitles that do not themselves
- specify a particular font. See also ``--subfont``. With fontconfig enabled
- the argument is a fontconfig pattern and the default is ``sans``. Without
- fontconfig the argument is a filename and the default is
- ``~/.mpv/subfont.ttf``.
-
- *EXAMPLE*:
-
- - ``--font=~/.mpv/arialuni.ttf`` (no fontconfig)
- - ``--font='Bitstream Vera Sans'`` (usual case with fontconfig)
- - ``--font='Bitstream Vera Sans:style=Bold'`` (usual case with fontconfig)
-
--force-window-position
Forcefully move mpv's video output window to default location whenever
there is a change in video parameters, video stream or file. This used to
@@ -1234,6 +1211,89 @@
--osd-duration=<time>
Set the duration of the OSD messages in ms (default: 1000).
+--osd-color=<#RRGGBB>
+ Specify the color used for OSD. This is also used for unstyled text
+ subtitles. This option (and most other ``--osd-`` options) are ignored
+ when ASS subtitles are rendered, unless the ``--no-ass`` option is
+ specified.
+
+ The color is specified in hex RGB, and each 2-digit group expresses a
+ color value in the range 0 (``00``) to 255 (`FF`). For example, ``#FF0000``
+ is red.
+
+ You can specify transparency by specifying an alpha value in the form
+ ``#AARRGGBB``. 0 is fully transparent, while ``FF`` is opaque (opaque is
+ default with the shorter color specification).
+
+--osd-back-color=<#RRGGBB>
+ See ``--osd-color``. Color used for OSD text background.
+
+--osd-border-color=<#RRGGBB>
+ See ``--osd-color``. Color used for the OSD font border.
+
+ *Note*: ignored when ``--osd-back-color`` is specified (or more
+ exactly: when that option is not set to completely transparent).
+
+--osd-shadow-color=<#RRGGBB>
+ See ``--osd-color``. Color used for OSD text shadow.
+
+--osd-font-size=<size>
+ Specify the OSD font size. The unit is the size in scaled pixels at a
+ window height of 720. The actual pixel size is scaled with the window
+ height: if the window height is larger or smaller than 720, the actual size
+ of the text increases or decreases as well.
+
+ Default: 45.
+
+--osd-border-size=<size>
+ Size of the OSD font border in scaled pixels (see ``--osd-font-size`` for
+ details). A value of 0 disables borders.
+
+ Default: 2.5.
+
+--osd-margin-x=<size>
+ Left and right screen margin for the OSD in scaled pixels (see
+ ``--osd-font-size`` for details).
+
+ This option specifies the distance of the OSD to the left, as well as at
+ which distance from the right border long OSD text will be broken.
+
+ Default: 25.
+
+--osd-margin-y=<size>
+ Top and bottom screen margin for the OSD in scaled pixels (see
+ ``--osd-font-size`` for details).
+
+ This option specifies the vertical margins of the OSD. This is also used
+ for unstyled text subtitles. If you just want to raise the vertical
+ subtitle position, use ``--sub-pos``.
+
+ Default: 10.
+
+--osd-shadow-offset=<size>
+ Displacement of the OSD text shadow in scaled pixels (see
+ ``--osd-font-size`` for details). A value of 0 disables shadows.
+
+ Default: 0.
+
+--osd-spacing=<size>
+ Horizontal OSD font spacing in scaled pixels (see ``--osd-font-size`` for
+ details). This value is added to the normal letter spacing. Negative values
+ are allowed.
+
+ Default: 0.
+
+--osd-font=<pattern>
+ Specify font to use for OSD and for subtitles that do not themselves
+ specify a particular font. The default is ``Sans``.
+
+ Typically ignored for ASS-subtitles.
+
+ *EXAMPLE*:
+
+ - ``--osd-font='Bitstream Vera Sans'``
+ - ``--osd-font='Bitstream Vera Sans:style=Bold'`` (fontconfig pattern)
+
--osd-fractions
Show OSD times with fractions of seconds.
@@ -1816,13 +1876,6 @@
Use ``--sub`` for normal text subtitle files.
---subfont=<pattern-or-filename>
- Sets the subtitle font (see ``--font``). If no ``--subfont`` is given,
- ``--font`` is used for subtitles too.
-
---subfont-text-scale=<0-100>
- Factor for the text subtitle and OSD font size (default: 6).
-
--subfps=<rate>
Specify the framerate of the subtitle file (default: movie fps).
@@ -1833,6 +1886,9 @@
Specify the position of subtitles on the screen. The value is the vertical
position of the subtitle in % of the screen height.
+--sub-scale=<0-100>
+ Factor for the text subtitle font size (default: 1).
+
--sws=<n>
Specify the software scaler algorithm to be used with the ``--zoom``
option. This affects video output drivers which lack hardware
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;
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index 503bd23188..079afbe17e 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -38,13 +38,46 @@
#include "stream/stream.h"
#include "core/options.h"
+void mp_ass_set_style(ASS_Style *style, struct osd_style_opts *opts)
+{
+ if (opts->font) {
+ free(style->FontName);
+ style->FontName = strdup(opts->font);
+ style->treat_fontname_as_pattern = 1;
+ }
+
+ // libass_font_size = FontSize * (window_height / MP_ASS_FONT_PLAYRESY)
+ // scale translates parameters from PlayResY=720 to MP_ASS_FONT_PLAYRESY
+ double scale = MP_ASS_FONT_PLAYRESY / 720.0;
+
+ style->FontSize = opts->font_size * scale;
+ style->PrimaryColour = MP_ASS_COLOR(opts->color);
+ style->SecondaryColour = style->PrimaryColour;
+ if (opts->back_color.a) {
+ style->OutlineColour = MP_ASS_COLOR(opts->back_color);
+ style->BorderStyle = 3; // opaque box
+ } else {
+ style->OutlineColour = MP_ASS_COLOR(opts->border_color);
+ style->BorderStyle = 1; // outline
+ }
+ style->BackColour = MP_ASS_COLOR(opts->shadow_color);
+ style->Outline = opts->border_size * scale;
+ style->Shadow = opts->shadow_offset * scale;
+ style->Spacing = opts->spacing * scale;
+ style->MarginL = opts->margin_x * scale;
+ style->MarginR = style->MarginL;
+ style->MarginV = opts->margin_y * scale;
+ style->ScaleX = 1.;
+ style->ScaleY = 1.;
+}
+
ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
{
ASS_Track *track = ass_new_track(library);
track->track_type = TRACK_TYPE_ASS;
track->Timer = 100.;
- track->PlayResY = 288;
+ track->PlayResY = MP_ASS_FONT_PLAYRESY;
track->WrapStyle = 0;
if (opts->ass_styles_file && opts->ass_style_override)
@@ -56,32 +89,8 @@ ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts)
track->default_style = sid;
ASS_Style *style = track->styles + sid;
style->Name = strdup("Default");
- style->FontName = sub_font_name ? strdup(sub_font_name)
- : font_name ? strdup(font_name) : strdup("Sans");
- style->treat_fontname_as_pattern = 1;
-
- double fs = track->PlayResY * text_font_scale_factor / 100.;
-
- uint32_t c1 = 0xFFFFFF00;
- uint32_t c2 = 0x00000000;
- if (opts->ass_color)
- c1 = strtoll(opts->ass_color, NULL, 16);
- if (opts->ass_border_color)
- c2 = strtoll(opts->ass_border_color, NULL, 16);
-
- style->FontSize = fs;
- style->PrimaryColour = c1;
- style->SecondaryColour = c1;
- style->OutlineColour = c2;
- style->BackColour = 0x00000000;
- style->BorderStyle = 1;
style->Alignment = 2;
- style->Outline = fs / 16;
- style->MarginL = 10;
- style->MarginR = 10;
- style->MarginV = 5;
- style->ScaleX = 1.;
- style->ScaleY = 1.;
+ mp_ass_set_style(style, opts->osd_style);
}
if (opts->ass_style_override)
@@ -231,7 +240,7 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
set_use_margins = opts->ass_use_margins;
set_sub_pos = 100 - sub_pos;
set_line_spacing = opts->ass_line_spacing;
- set_font_scale = opts->ass_font_scale;
+ set_font_scale = opts->sub_scale;
set_hinting = opts->ass_hinting & 3; // +4 was for no hinting if scaled
}
@@ -244,27 +253,20 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
ass_set_line_spacing(priv, set_line_spacing);
}
-void mp_ass_configure_fonts(ASS_Renderer *priv)
+void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts)
{
- char *dir, *path, *family;
+ char *dir, *path;
dir = get_path("fonts");
path = get_path("subfont.ttf");
if (!mp_path_exists(path)) {
free(path);
path = NULL;
}
- if (sub_font_name)
- family = strdup(sub_font_name);
- else if (font_name)
- family = strdup(font_name);
- else
- family = 0;
- ass_set_fonts(priv, path, family, 1, NULL, 1);
+ ass_set_fonts(priv, path, opts->font, 1, NULL, 1);
free(dir);
free(path);
- free(family);
}
void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,
diff --git a/sub/ass_mp.h b/sub/ass_mp.h
index c3dbc5e28f..e0a5917fa4 100644
--- a/sub/ass_mp.h
+++ b/sub/ass_mp.h
@@ -27,12 +27,24 @@
#include "config.h"
#include "subreader.h"
+// font sizes and explicit tags in subassconvert.c assume this size (?)
+#define MP_ASS_FONT_PLAYRESY 288
+
+#define MP_ASS_RGBA(r, g, b, a) \
+ (((r) << 24U) | ((g) << 16) | ((b) << 8) | (0xFF - (a)))
+
+// m_color argument
+#define MP_ASS_COLOR(c) MP_ASS_RGBA((c).r, (c).g, (c).b, (c).a)
+
#ifdef CONFIG_ASS
#include <ass/ass.h>
#include <ass/ass_types.h>
struct MPOpts;
struct mp_osd_res;
+struct osd_style_opts;
+
+void mp_ass_set_style(ASS_Style *style, struct osd_style_opts *opts);
ASS_Track *mp_ass_default_track(ASS_Library *library, struct MPOpts *opts);
ASS_Track *mp_ass_read_subdata(ASS_Library *library, struct MPOpts *opts,
@@ -43,7 +55,7 @@ ASS_Track *mp_ass_read_stream(ASS_Library *library, const char *fname,
struct MPOpts;
void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts,
struct mp_osd_res *dim);
-void mp_ass_configure_fonts(ASS_Renderer *priv);
+void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts);
ASS_Library *mp_ass_init(struct MPOpts *opts);
struct sub_bitmap;
diff --git a/sub/osd_libass.c b/sub/osd_libass.c
index 8e7d766024..749b46d6ae 100644
--- a/sub/osd_libass.c
+++ b/sub/osd_libass.c
@@ -46,7 +46,7 @@ void osd_init_backend(struct osd_state *osd)
sizeof(osd_font_pfb) - 1);
osd->osd_render = ass_renderer_init(osd->osd_ass_library);
- mp_ass_configure_fonts(osd->osd_render);
+ mp_ass_configure_fonts(osd->osd_render, osd->opts->osd_style);
ass_set_aspect_ratio(osd->osd_render, 1.0, 1.0);
}
@@ -59,30 +59,27 @@ void osd_destroy_backend(struct osd_state *osd)
osd->osd_ass_library = NULL;
}
-static void update_font_style(ASS_Track *track, ASS_Style *style, double factor)
-{
- // Set to neutral base direction, as opposed to VSFilter LTR default
- style->Encoding = -1;
-
- // duplicated from ass_mp.c
- style->FontSize = track->PlayResY * factor / 100.;
- style->Outline = style->FontSize / 16;
-}
-
-
static ASS_Track *create_osd_ass_track(struct osd_state *osd)
{
- ASS_Track *track = mp_ass_default_track(osd->osd_ass_library, osd->opts);
- ASS_Style *style = track->styles + track->default_style;
+ ASS_Track *track = ass_new_track(osd->osd_ass_library);
+ track->track_type = TRACK_TYPE_ASS;
+ track->Timer = 100.;
+ track->PlayResY = MP_ASS_FONT_PLAYRESY;
track->PlayResX = track->PlayResY * 1.33333;
-
- update_font_style(track, style, text_font_scale_factor);
-
- style->Alignment = 5;
-
- free(style->FontName);
- style->FontName = strdup(font_name ? font_name : "Sans");
+ track->WrapStyle = 1; // end-of-line wrapping instead of smart wrapping
+
+ if (track->n_styles == 0) {
+ track->Kerning = true;
+ int sid = ass_alloc_style(track);
+ track->default_style = sid;
+ ASS_Style *style = track->styles + sid;
+ style->Alignment = 5; // top-title, left
+ style->Name = strdup("OSD");
+ mp_ass_set_style(style, osd->opts->osd_style);
+ // Set to neutral base direction, as opposed to VSFilter LTR default
+ style->Encoding = -1;
+ }
return track;
}
@@ -172,7 +169,7 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
- style->Alignment = 10;
+ style->Alignment = 10; // all centered
style->MarginL = style->MarginR = style->MarginV = 0;
// We need a fixed font size with respect to the OSD width.
@@ -226,9 +223,12 @@ static void update_sub(struct osd_state *osd, struct osd_object *obj)
if (!obj->osd_track)
obj->osd_track = mp_ass_default_track(osd->osd_ass_library, osd->opts);
+ struct osd_style_opts font = *opts->osd_style;
+ font.font_size *= opts->sub_scale;
+
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
+ mp_ass_set_style(style, &font);
- update_font_style(obj->osd_track, style, text_font_scale_factor);
#if LIBASS_VERSION >= 0x01010000
ass_set_line_position(osd->osd_render, 100 - sub_pos);
#endif
diff --git a/sub/sub.c b/sub/sub.c
index eafa2cc831..8fde350d4d 100644
--- a/sub/sub.c
+++ b/sub/sub.c
@@ -63,18 +63,47 @@ int sub_pos=100;
int sub_visibility=1;
subtitle* vo_sub=NULL;
-float text_font_scale_factor = 6;
-char *font_name = NULL;
-char *sub_font_name = NULL;
float sub_delay = 0;
float sub_fps = 0;
void *vo_spudec=NULL;
void *vo_vobsub=NULL;
-static struct osd_state *global_osd;
+static const const struct osd_style_opts osd_style_opts_def = {
+ .font = "Sans",
+ .font_size = 45,
+ .color = {255, 255, 255, 255},
+ .border_color = {0, 0, 0, 255},
+ .shadow_color = {240, 240, 240, 128},
+ .border_size = 2.5,
+ .shadow_offset = 0,
+ .margin_x = 25,
+ .margin_y = 10,
+};
+#undef OPT_BASE_STRUCT
+#define OPT_BASE_STRUCT struct osd_style_opts
+const struct m_sub_options osd_style_conf = {
+ .opts = (m_option_t[]) {
+ OPT_STRING("font", font, 0),
+ OPT_FLOATRANGE("font-size", font_size, 0, 1, 9000),
+ OPT_COLOR("color", color, 0),
+ OPT_COLOR("border-color", border_color, 0),
+ OPT_COLOR("shadow-color", shadow_color, 0),
+ OPT_COLOR("back-color", back_color, 0),
+ OPT_FLOATRANGE("border-size", border_size, 0, 0, 10),
+ OPT_FLOATRANGE("shadow-offset", shadow_offset, 0, 0, 10),
+ OPT_FLOATRANGE("spacing", spacing, 0, -10, 10),
+ OPT_INTRANGE("margin-x", margin_x, 0, 0, 300),
+ OPT_INTRANGE("margin-y", margin_y, 0, 0, 600),
+ {0}
+ },
+ .size = sizeof(struct osd_style_opts),
+ .defaults = &osd_style_opts_def,
+};
+
+static struct osd_state *global_osd;
static bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
{
@@ -265,6 +294,14 @@ void vo_osd_changed(int new_value)
osd->want_redraw = true;
}
+void osd_subs_changed(struct osd_state *osd)
+{
+ for (int n = 0; n < MAX_OSD_PARTS; n++) {
+ if (osd->objs[n]->is_sub)
+ vo_osd_changed(n);
+ }
+}
+
bool sub_bitmaps_bb(struct sub_bitmaps *imgs, struct mp_rect *out_bb)
{
struct mp_rect bb = {INT_MAX, INT_MAX, INT_MIN, INT_MIN};
diff --git a/sub/sub.h b/sub/sub.h
index cdc094d290..f894682596 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -23,6 +23,8 @@
#include <stdbool.h>
#include <stdint.h>
+#include "core/m_option.h"
+
// NOTE: VOs must support at least SUBBITMAP_LIBASS and SUBBITMAP_RGBA.
enum sub_bitmap_format {
SUBBITMAP_EMPTY = 0,// no bitmaps; always has num_parts==0
@@ -172,6 +174,22 @@ enum mp_osd_font_codepoints {
OSD_PB_1 = 0x13,
};
+struct osd_style_opts {
+ char *font;
+ float font_size;
+ struct m_color color;
+ struct m_color border_color;
+ struct m_color shadow_color;
+ struct m_color back_color;
+ float border_size;
+ float shadow_offset;
+ float spacing;
+ int margin_x;
+ int margin_y;
+};
+
+extern const struct m_sub_options osd_style_conf;
+
/* now in textform */
extern char * const sub_osd_names[];
extern char * const sub_osd_names_short[];
@@ -181,10 +199,6 @@ extern int sub_utf8;
extern char *sub_cp;
extern int sub_pos;
-extern float text_font_scale_factor;
-
-extern char *font_name;
-extern char *sub_font_name;
extern float sub_delay;
extern float sub_fps;
@@ -192,6 +206,7 @@ extern float sub_fps;
struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib);
void osd_set_text(struct osd_state *osd, const char *text);
void vo_osd_changed(int new_value);
+void osd_subs_changed(struct osd_state *osd);
void osd_free(struct osd_state *osd);
enum mp_osd_draw_flags {