summaryrefslogtreecommitdiffstats
path: root/sub/sub.c
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 /sub/sub.c
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 'sub/sub.c')
-rw-r--r--sub/sub.c45
1 files changed, 41 insertions, 4 deletions
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};