Skip to content

Commit

Permalink
sub: use Unicode linebreaking for non-ASS subs and OSD
Browse files Browse the repository at this point in the history
ASS must only automatically break at ASCII spaces (\x20), but other
subtitle formats might expect more breaking oppurtinities.
Especially non-ASS subs in scripts, which typically do not use (ASCII)
spaces to seperate words, like e.g. CJK, might overflow the screen
if the conversion didn't insert additional linebreaks (ffmpeg does not).

Thus try to enable Unicode linebreaking for converted subs and the OSD
if libass is new enough. The feature may still be unavailable at runtime
if libass wasn't build with Unicode linebreaking support.
  • Loading branch information
TheOneric authored and sfan5 committed Sep 19, 2022
1 parent ba81e4e commit 9e3ec04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sub/osd_libass.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ static void create_ass_track(struct osd_state *osd, struct osd_object *obj,
track->WrapStyle = 1; // end-of-line wrapping instead of smart wrapping
track->Kerning = true;
track->ScaledBorderAndShadow = true;

#if LIBASS_VERSION >= 0x01600010
ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
#endif
update_playres(ass, &obj->vo_res);
}

Expand Down
4 changes: 4 additions & 0 deletions sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim,
ass_set_font_scale(priv, set_font_scale);
ass_set_hinting(priv, set_hinting);
ass_set_line_spacing(priv, set_line_spacing);
#if LIBASS_VERSION >= 0x01600010
if (converted)
ass_track_set_feature(track, ASS_FEATURE_WRAP_UNICODE, 1);
#endif
}

static bool has_overrides(char *s)
Expand Down

0 comments on commit 9e3ec04

Please sign in to comment.