#include <stdarg.h>
#include "ass_types.h"
-#define LIBASS_VERSION 0x01103000
+#define LIBASS_VERSION 0x01103001
/*
* A linked list of images produced by an ass renderer.
ASS_SHAPING_COMPLEX
} ASS_ShapingLevel;
+/**
+ * \brief Style override options. See
+ * ass_set_selective_style_override_enabled() for details.
+ */
+typedef enum {
+ ASS_OVERRIDE_BIT_STYLE = 1,
+ ASS_OVERRIDE_BIT_FONT_SIZE = 2,
+} ASS_OverrideBits;
+
/**
* \brief Return the version of library. This returns the value LIBASS_VERSION
* was set to when the library was compiled.
* only be implemented on "best effort" basis, and has to rely on
* heuristics that can easily break.
* \param priv renderer handle
- * \param enable enable selective styling if the value is not 0
- */
-void ass_set_selective_style_override_enabled(ASS_Renderer *priv, int enable);
+ * \param bits bit mask comprised of ASS_OverrideBits values. If the value is
+ * 0, all override features are disabled, and libass will behave like libass
+ * versions before this feature was introduced. Possible values:
+ * ASS_OVERRIDE_BIT_STYLE: apply the style as set with
+ * ass_set_selective_style_override() on events which look like
+ * dialogue. Other style overrides are also applied this way, except
+ * ass_set_font_scale(). How ass_set_font_scale() is applied depends
+ * on the ASS_OVERRIDE_BIT_FONT_SIZE flag.
+ * ASS_OVERRIDE_BIT_FONT_SIZE: apply ass_set_font_scale() only on events
+ * which look like dialogue. If not set, it is applied to all
+ * events.
+ * 0: ignore ass_set_selective_style_override(), but apply all other
+ * overrides (traditional behavior).
+ */
+void ass_set_selective_style_override_enabled(ASS_Renderer *priv, int bits);
/**
* \brief Set style for selective style override.
ASS_Style *script = render_priv->track->styles +
render_priv->state.event->Style;
ASS_Style *new = &render_priv->state.override_style_temp_storage;
- int override = !event_is_positioned(render_priv->state.event->Text);
+ int explicit = event_is_positioned(render_priv->state.event->Text);
+ int requested = render_priv->settings.selective_style_overrides;
double scale;
if (!rstyle)
rstyle = script;
render_priv->state.style = script;
+ render_priv->state.overrides = ASS_OVERRIDE_BIT_FONT_SIZE; // odd default
- if (!override || !render_priv->settings.selective_style_overrides)
+ if (explicit && (requested & ASS_OVERRIDE_BIT_FONT_SIZE))
+ render_priv->state.overrides &= ~(unsigned)ASS_OVERRIDE_BIT_FONT_SIZE;
+
+ if (!explicit && (requested & ASS_OVERRIDE_BIT_STYLE))
+ render_priv->state.overrides |= ASS_OVERRIDE_BIT_STYLE;
+
+ if (!(render_priv->state.overrides & ASS_OVERRIDE_BIT_STYLE))
return rstyle;
// Create a new style that contains a mix of the original style and
if (!settings_priv->storage_height)
render_priv->blur_scale = render_priv->border_scale;
- render_priv->font_scale *= settings_priv->font_size_coeff;
- render_priv->border_scale *= settings_priv->font_size_coeff;
- render_priv->blur_scale *= settings_priv->font_size_coeff;
+ if (render_priv->state.overrides & ASS_OVERRIDE_BIT_FONT_SIZE) {
+ render_priv->font_scale *= settings_priv->font_size_coeff;
+ render_priv->border_scale *= settings_priv->font_size_coeff;
+ render_priv->blur_scale *= settings_priv->font_size_coeff;
+ }
}
/**
int wrap_style;
int font_encoding;
+ // combination of ASS_OVERRIDE_BIT_* flags that apply right now
+ unsigned overrides;
+
// used to store RenderContext.style when doing selective style overrides
ASS_Style override_style_temp_storage;
} RenderContext;
default_font, fc, config, update);
}
-void ass_set_selective_style_override_enabled(ASS_Renderer *priv, int enable)
+void ass_set_selective_style_override_enabled(ASS_Renderer *priv, int bits)
{
- enable = !!enable;
- if (priv->settings.selective_style_overrides != enable) {
- priv->settings.selective_style_overrides = enable;
+ if (priv->settings.selective_style_overrides != bits) {
+ priv->settings.selective_style_overrides = bits;
ass_reconfigure(priv);
}
}