// res_y should be track->PlayResY // It determines scaling of font sizes and more. void mp_ass_set_style(ASS_Style *style, int res_y, struct osd_style_opts *opts) { if (opts->font) { free(style->FontName); style->FontName = strdup(opts->font); style->treat_fontname_as_pattern = 1; } // libass_font_size = FontSize * (window_height / res_y) // scale translates parameters from PlayResY=720 to res_y double scale = res_y / 720.0; style->FontSize = opts->font_size * scale; style->PrimaryColour = MP_ASS_COLOR(opts->color); style->SecondaryColour = style->PrimaryColour; if (opts->back_color.a) { style->OutlineColour = MP_ASS_COLOR(opts->back_color); style->BorderStyle = 3; // opaque box } else { style->OutlineColour = MP_ASS_COLOR(opts->border_color); style->BorderStyle = 1; // outline } style->BackColour = MP_ASS_COLOR(opts->shadow_color); style->Outline = opts->border_size * scale; style->Shadow = opts->shadow_offset * scale; style->Spacing = opts->spacing * scale; style->MarginL = opts->margin_x * scale; style->MarginR = style->MarginL; style->MarginV = opts->margin_y * scale; style->ScaleX = 1.; style->ScaleY = 1.; #if LIBASS_VERSION >= 0x01020000 style->Blur = opts->blur; #endif }
// res_y should be track->PlayResY // It determines scaling of font sizes and more. void mp_ass_set_style(ASS_Style *style, double res_y, const struct osd_style_opts *opts) { if (opts->font) { if (!style->FontName || strcmp(style->FontName, opts->font) != 0) { free(style->FontName); style->FontName = strdup(opts->font); } } // libass_font_size = FontSize * (window_height / res_y) // scale translates parameters from PlayResY=720 to res_y double scale = res_y / 720.0; style->FontSize = opts->font_size * scale; style->PrimaryColour = MP_ASS_COLOR(opts->color); style->SecondaryColour = style->PrimaryColour; style->OutlineColour = MP_ASS_COLOR(opts->border_color); if (opts->back_color.a) { style->BackColour = MP_ASS_COLOR(opts->back_color); style->BorderStyle = 4; // opaque box } else { style->BackColour = MP_ASS_COLOR(opts->shadow_color); style->BorderStyle = 1; // outline } style->Outline = opts->border_size * scale; style->Shadow = opts->shadow_offset * scale; style->Spacing = opts->spacing * scale; style->MarginL = opts->margin_x * scale; style->MarginR = style->MarginL; style->MarginV = opts->margin_y * scale; style->ScaleX = 1.; style->ScaleY = 1.; style->Alignment = 1 + (opts->align_x + 1) + (opts->align_y + 2) % 3 * 4; style->Blur = opts->blur; style->Bold = opts->bold; }