ASS Fixes 4: Properly handle Margins, adjust for Padding Bug and manage Margins for Abs Positioning#404
ASS Fixes 4: Properly handle Margins, adjust for Padding Bug and manage Margins for Abs Positioning#404softworkz wants to merge 2 commits intoffmpeginteropx:masterfrom
Conversation
ExplanationsWinUI Bug in Handling TimedTextPaddingI have seen that the margins from the defined styles (neither others) are not having the expected effect. As long as this is not fixed, we need to workaround by switching Before/After and Start/End when using TimedTextPadding as done in this PR. Style Margins and Dialogue MarginsThe current code is ignoring margins from the style definition when only a single margin value is specified in a dialogue line. MarginV HandlingMarginV is a top margin for top-aligned blocks and a bottom margin for bottom-aligned blocks even though the Word doc tells this for style defined margins and otherwise for dialog lines, where it talks about bottom only - which is incorrect (according to AegiSub behavior). Handling Margins in Case of Absolute PositioningMarginV is unused in case of absolute posiioned elements, but MarginL and MarginR still need to be applied. |
|
|
||
| // Now subtract the reduced width from the padding (which is meant to | ||
| // be applied to a 100% width box) | ||
| padding1.After -= (100 - extent.Width); |
There was a problem hiding this comment.
I do not really understand why the right margin needs to be reduced here (and below). But I guess you tested this with actual files, comparing with how Aegisub renders them, right?
There was a problem hiding this comment.
Yes I did. You can easily do for yourself like this:
In Aegisub, open any ASS file and then create a dummy video for it.
Detach the video window (just for ease).
Double-Click an event.
Then you get there:
By double-clicking, you can set the position.
By adding {\anX}, you can change the alignment.
And now you can play with different margins:
You'll see that Aegisub always calculates with a width of 100% and then it applies the L/R margins, but when left or right aligned, it adds both margins to the opposite side.
Since we cannot have a width of 100% but need to reduce it so the region fits into the video frame, we need to subtract this reduced width from the margins (because it's like as if we had already applied this reduced width as a margin).


SubtitleProviderSsaAss: Handle margins when absolute positioning
SubtitleProviderSsaAss: Reverse margins