Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect position after vector drawing #230

Closed
Argon- opened this issue Jul 8, 2016 · 7 comments
Closed

Incorrect position after vector drawing #230

Argon- opened this issue Jul 8, 2016 · 7 comments
Labels

Comments

@Argon-
Copy link

Argon- commented Jul 8, 2016

When using a vector drawing with negative x values then the position after the drawing is incorrect.
Small example:

{\shad0}{\alpha&H00}{\p1}{\bord0.5}{\3c&H0000FF&}
{\1c&H262626&}m 0 60 l 190 60 190 0 0 0{\p0}{\bord0}
{\1c&HFFFFFF}{\p1}m 0 0 n 0 50 l -190 50 -190 60 0 60{\p0}{\r}{\fs100}I

This is a black/gray box (first vector drawing) followed by a white box drawn over the first box by using negative x values followed by a single letter I. The resulting drawing looks as expected (all screenshot from a Aegisub built from 2014, results are the same using mpv with libass, both built today from git):

screen shot 2016-07-08 at 9 27 42 pm

Note the correctly overlapping drawings but the wide space between the drawings and the letter I. Now the same without negative x values in the second vector drawing:

{\shad0}{\alpha&H00}{\p1}{\bord0.5}{\3c&H0000FF&}
{\1c&H262626&}m 0 60 l 190 60 190 0 0 0{\p0}{\bord0}
{\1c&HFFFFFF}{\p1}m 0 0 n 0 50 l 190 50 190 60 0 60{\p0}{\r}{\fs100}I

Result:

screen shot 2016-07-08 at 9 29 47 pm

For me it looks like the calculation for the spacing/position of the letter does not consider the signum of the x value which I'd consider a bug.
Or am I getting something totally wrong?

@astiob
Copy link
Member

astiob commented Jul 8, 2016

The width of a vector drawing is its maximum x coordinate minus its minimum x coordinate, which in both of your examples happens to be 190. Similarly, the line height that a drawing needs is calculated as its maximum y coordinate minus its minimum y coordinate.

This is mainly to maintain compatibility with VSFilter, whose reason for doing so is unknown. Even if this behaviour was originally unintentional in VSFilter, it is not going to be changed, because many existing scripts probably rely on it.

The only way to emulate a drawing with a nonpositive width that I can think of is to split the line into two:

Dialogue: ...,{\an2\pos(640,700)\shad0\bord0.5\alpha&H00&\1c&H262626&\3c&H0000FF&\p1}m 0 60 l 190 60 190 0 0 0{\bord0\1c&HFFFFFF&}m 0 0 n 0 50 l -190 50 -190 60 0 60
Dialogue: ...,{\an2\pos(735,700)\fs100}I

or

Dialogue: ...,{\an2\pos(640,700)\shad0\bord0.5\alpha&H00&\1c&H262626&\3c&H0000FF&\p1}m 0 60 l 190 60 190 0 0 0{\bord0\1c&HFFFFFF&}m 0 0 n 0 50 l -190 50 -190 60 0 60
Dialogue: ...,{\an2\pos(640,700)\alpha&HFF&\p1}m 0 60 l 190 60 190 0 0 0{\p0\r\fs100}I

In your particular case, if you don’t actually need the 0.5 pixel border, you should be able to achieve the same result in a single line using a black foreground and a white shadow.

@Argon-
Copy link
Author

Argon- commented Jul 8, 2016

Oh wow, I suddenly start to hate VSFilter.
Unfortunately, my actual use-case is not as simple as the example above. What I'm actually doing is drawing a graph that I intend to display with mpv (therefore I don't have multiple lines). This works:
3f778106-2fa0-11e6-8453-85fe71933ced
But the mentioned behavior makes it impossible to have text behind the graph. In my case I wanted to place the graph at the front of a line and the text behind it because I found no way to align them without absolute coordinates.

Is there maybe a way to put the cursor "back" (to the left), directly after the vector drawings, so that text would start from there, or will text always honor the "width" of a vector drawing?

@ghost
Copy link

ghost commented Jul 8, 2016

Oh wow, I suddenly start to hate VSFilter.

Only now?

@astiob
Copy link
Member

astiob commented Aug 15, 2016

Is there maybe a way to put the cursor "back" (to the left), directly after the vector drawings, so that text would start from there, or will text always honor the "width" of a vector drawing?

No, I’m afraid there is no way to do that, sorry.

Hm, here’s another idea for you. How about this: write out your first line consisting of a drawing followed by some text, then \N, and then a second line consisting of a drawing with all vertical coordinates shifted by the value of \fs or simply with \pbo set to the same amount, to make it appear visually on the previous line.

@Argon-
Copy link
Author

Argon- commented Aug 26, 2016

This would cause a problem as I'm still writing text on every line and I'd somehow have to re-position the cursor.
In my case now I "solved" it by putting the graph at the end of a line, so the problem is no longer visible as no text does follow the svg drawing. Not a real fix but works.
Should this issue stay open? I'm fine with closing it, as it won't change anyway I assume.

@astiob
Copy link
Member

astiob commented Jan 11, 2017

I guess we may as well close this. I’m sorry that we couldn’t find a good solution for you.

@astiob
Copy link
Member

astiob commented Dec 9, 2020

This is old, but would it not be possible to use something like \pos(-200,0) and start each line with a drawing with coordinates in the 200–400 range, follow that up with a second drawing using coordinates in the 0–200 range, and then the text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants