From 07acdf09b3f067f7e48ac05573893cc2ff626928 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Fri, 14 Jun 2024 01:56:24 -0400 Subject: [PATCH] sd_ass: fix margin y scale with font size --sub-margin-y is documented to scale with font size, which is scaled "by" or "with" window depending on the options. However, when using ass_set_font_scale to change font size, the y margin isn't scaled, so it is still scaled to video size. This causes the y margin size becoming smaller when the video becomes smaller, even when the font size isn't changing. Fix this by also scale the MarginV with the font scale. Also use lrint instead of round. --- sub/sd_ass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 0333216379..c32e339a50 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -592,8 +592,9 @@ static void configure_ass(struct sd *sd, struct mp_osd_res *dim, track->PlayResX = track->PlayResY * (double)vidw / MPMAX(vidh, 1); double fix_margins = track->PlayResX / (double)old_playresx; for (int n = 0; n < track->n_styles; n++) { - track->styles[n].MarginL = round(track->styles[n].MarginL * fix_margins); - track->styles[n].MarginR = round(track->styles[n].MarginR * fix_margins); + track->styles[n].MarginL = lrint(track->styles[n].MarginL * fix_margins); + track->styles[n].MarginR = lrint(track->styles[n].MarginR * fix_margins); + track->styles[n].MarginV = lrint(track->styles[n].MarginV * set_font_scale); } } }