libass / libass

libass is a portable subtitle renderer for the ASS/SSA (Advanced Substation Alpha/Substation Alpha) subtitle format.
ISC License
936 stars 217 forks source link

Issue with n command in drawings #435

Open rcombs opened 4 years ago

rcombs commented 4 years ago

{\p1\pos(0,0)\an7}m 100 100 l 100 200 l 200 300 n 50 50 l 300 50 libass: image vsfilter: image

I'm not sure how vsfilter does anything with this command, looking at the code, but apparently it does what appears to be the same was what we do if you replace the n with an l????

This was discovered by @The0x539; I'm not aware of it existing in any real scripts, so not super worrisome, at least.

rcombs commented 4 years ago

At a bit of investigation, it looks like n acts like l if it's followed by any non-n non-m command; if it's followed by another n, an m, or the end of the drawing, it's ignored. I'm not sure if this was deliberate, but it's how it works. This is because the _EvaluateLine function checks if the current cursor position matches the position of the previous point, and if not, draws a line to the previous point (thus updating the cursor) before continuing. This applies to beziers/splines as well, since they're implemented by calling _EvaluateLine in a loop. n adds a point to the list, but doesn't move the cursor, so it ends up triggering this.

astiob commented 4 years ago

Yep, looks the same way to me.

astiob commented 4 years ago

Except when m is followed by (a number of) n and then followed by a cubic curve. Then the (last) n overrides the m.