mirror of https://github.com/mpv-player/mpv
subtitles: change default libass rendering style
Change the default style used for rendering plaintext subtitles with libass. The following attributes change: * FontSize: Increase the size multiplier used with the default -subfont-autoscale 3 from 1.4 to 1.7, thus making the font 21% larger. Actually implementing the -subfont-autoscale modes other than 1 would give a multiplier of 5/3=1.67 for 4:3 aspect ratio video, sqrt(337)/9=2.04 for 16:9. * PrimaryColour: Change color from yellow to white. * Outline: Before this was 2 regardless of user font size choice. Make it FontSize/16 instead. With default font size this is about half the previous width. * Kerning: Enable kerning for the track. There won't be styling designed for VSFilter's lack of kerning, and hopefully people won't use broken fonts with bad kerning tables for the default font either.
This commit is contained in:
parent
304cafd31d
commit
828af33bfe
34
ass_mp.c
34
ass_mp.c
|
@ -70,8 +70,6 @@ extern char *sub_cp;
|
||||||
static char *sub_cp = 0;
|
static char *sub_cp = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void process_force_style(ASS_Track *track);
|
|
||||||
|
|
||||||
ASS_Track *mp_ass_default_track(ASS_Library *library)
|
ASS_Track *mp_ass_default_track(ASS_Library *library)
|
||||||
{
|
{
|
||||||
ASS_Track *track = ass_new_track(library);
|
ASS_Track *track = ass_new_track(library);
|
||||||
|
@ -85,13 +83,9 @@ ASS_Track *mp_ass_default_track(ASS_Library *library)
|
||||||
ass_read_styles(track, ass_styles_file, sub_cp);
|
ass_read_styles(track, ass_styles_file, sub_cp);
|
||||||
|
|
||||||
if (track->n_styles == 0) {
|
if (track->n_styles == 0) {
|
||||||
ASS_Style *style;
|
track->Kerning = true;
|
||||||
int sid;
|
int sid = ass_alloc_style(track);
|
||||||
double fs;
|
ASS_Style *style = track->styles + sid;
|
||||||
uint32_t c1, c2;
|
|
||||||
|
|
||||||
sid = ass_alloc_style(track);
|
|
||||||
style = track->styles + sid;
|
|
||||||
style->Name = strdup("Default");
|
style->Name = strdup("Default");
|
||||||
style->FontName = (font_fontconfig >= 0
|
style->FontName = (font_fontconfig >= 0
|
||||||
&& sub_font_name) ? strdup(sub_font_name)
|
&& sub_font_name) ? strdup(sub_font_name)
|
||||||
|
@ -99,30 +93,34 @@ ASS_Track *mp_ass_default_track(ASS_Library *library)
|
||||||
&& font_name) ? strdup(font_name) : strdup("Sans");
|
&& font_name) ? strdup(font_name) : strdup("Sans");
|
||||||
style->treat_fontname_as_pattern = 1;
|
style->treat_fontname_as_pattern = 1;
|
||||||
|
|
||||||
fs = track->PlayResY * text_font_scale_factor / 100.;
|
double fs = track->PlayResY * text_font_scale_factor / 100.;
|
||||||
// approximate autoscale coefficients
|
/* The font size is always proportional to video height only;
|
||||||
|
* real -subfont-autoscale behavior is not implemented.
|
||||||
|
* Apply a correction that corresponds to about 4:3 aspect ratio
|
||||||
|
* video to get a size somewhat closer to what non-libass rendering
|
||||||
|
* would produce with the same text_font_scale_factor
|
||||||
|
* and subtitle_autoscale.
|
||||||
|
*/
|
||||||
if (subtitle_autoscale == 2)
|
if (subtitle_autoscale == 2)
|
||||||
fs *= 1.3;
|
fs *= 1.3;
|
||||||
else if (subtitle_autoscale == 3)
|
else if (subtitle_autoscale == 3)
|
||||||
fs *= 1.4;
|
fs *= 1.7;
|
||||||
style->FontSize = fs;
|
|
||||||
|
|
||||||
|
uint32_t c1 = 0xFFFFFF00;
|
||||||
|
uint32_t c2 = 0x00000000;
|
||||||
if (ass_color)
|
if (ass_color)
|
||||||
c1 = strtoll(ass_color, NULL, 16);
|
c1 = strtoll(ass_color, NULL, 16);
|
||||||
else
|
|
||||||
c1 = 0xFFFF0000;
|
|
||||||
if (ass_border_color)
|
if (ass_border_color)
|
||||||
c2 = strtoll(ass_border_color, NULL, 16);
|
c2 = strtoll(ass_border_color, NULL, 16);
|
||||||
else
|
|
||||||
c2 = 0x00000000;
|
|
||||||
|
|
||||||
|
style->FontSize = fs;
|
||||||
style->PrimaryColour = c1;
|
style->PrimaryColour = c1;
|
||||||
style->SecondaryColour = c1;
|
style->SecondaryColour = c1;
|
||||||
style->OutlineColour = c2;
|
style->OutlineColour = c2;
|
||||||
style->BackColour = 0x00000000;
|
style->BackColour = 0x00000000;
|
||||||
style->BorderStyle = 1;
|
style->BorderStyle = 1;
|
||||||
style->Alignment = 2;
|
style->Alignment = 2;
|
||||||
style->Outline = 2;
|
style->Outline = fs / 16;
|
||||||
style->MarginL = 10;
|
style->MarginL = 10;
|
||||||
style->MarginR = 10;
|
style->MarginR = 10;
|
||||||
style->MarginV = 5;
|
style->MarginV = 5;
|
||||||
|
|
Loading…
Reference in New Issue