This allows users to change the vertical position of normal subtitles.
MPlayer has such a feature as -sub-pos option using its internal
subtitle renderer.
Bump LIBASS_VERSION to indicate the API addition.
-AC_INIT(libass, 0.10.0)
+AC_INIT(libass, 0.10.1)
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([m4])
# Disable C++/Fortran checks
#include <stdarg.h>
#include "ass_types.h"
-#define LIBASS_VERSION 0x01000000
+#define LIBASS_VERSION 0x01010000
/*
* A linked list of images produced by an ass renderer.
*/
void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing);
+/**
+ * \brief Set vertical line position.
+ * \param priv renderer handle
+ * \param line_position vertical line position of subtitles in percent
+ * (0-100: 0 = on the bottom (default), 100 = on top)
+ */
+void ass_set_line_position(ASS_Renderer *priv, double line_position);
+
/**
* \brief Set font lookup defaults.
* \param default_font path to default font to use. Must be supplied if
y2scr(render_priv, render_priv->track->PlayResY / 2.0);
device_y = scr_y - (bbox.yMax + bbox.yMin) / 2.0;
} else { // subtitle
- double scr_y;
+ double scr_top, scr_bottom, scr_y0;
if (valign != VALIGN_SUB)
ass_msg(render_priv->library, MSGL_V,
"Invalid valign, assuming 0 (subtitle)");
- scr_y =
+ scr_bottom =
y2scr_sub(render_priv,
render_priv->track->PlayResY - MarginV);
- device_y = scr_y;
+ scr_top = y2scr_top(render_priv, 0); //xxx not always 0?
+ device_y = scr_bottom + (scr_top - scr_bottom) *
+ render_priv->settings.line_position / 100.0;
device_y -= text_info->height;
device_y += text_info->lines[0].asc;
+ // clip to top to avoid confusion if line_position is very high,
+ // turning the subtitle into a toptitle
+ // also, don't change behavior if line_position is not used
+ scr_y0 = scr_top + text_info->lines[0].asc;
+ if (device_y < scr_y0 && render_priv->settings.line_position > 0) {
+ device_y = scr_y0;
+ }
}
} else if (render_priv->state.evt_type == EVENT_VSCROLL) {
if (render_priv->state.scroll_direction == SCROLL_TB)
int frame_height;
double font_size_coeff; // font size multiplier
double line_spacing; // additional line spacing (in frame pixels)
+ double line_position; // vertical position for subtitles, 0-100 (0 = no change)
int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin.
int bottom_margin; // height of bottom margin. (frame_height - top_margin - bottom_margin) is original video height.
int left_margin;
priv->settings.line_spacing = line_spacing;
}
+void ass_set_line_position(ASS_Renderer *priv, double line_position)
+{
+ if (priv->settings.line_position != line_position) {
+ priv->settings.line_position = line_position;
+ ass_reconfigure(priv);
+ }
+}
+
void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
const char *default_family, int fc, const char *config,
int update)
ass_set_cache_limits
ass_flush_events
ass_set_shaper
+ass_set_line_position