irrwahn / svg2ass

Svg2ass - convert SVG vector graphics to ASS subtitle draw instructions.
BSD 3-Clause "New" or "Revised" License
34 stars 4 forks source link

Allow changing the size of coordinate system #3

Open qgustavor opened 3 years ago

qgustavor commented 3 years ago

One of the features of svg2ssa is allowing changing the size of coordinate system to improve precision. This feature is documented here changes \p1 to \p# where # is a integer.

Checking the current code scaling mode is fixed at \p1. From my experiments seems implementing such a feature is just a matter of adding a setting for it, changing the line linked above to return \p# and scaling values as needed (positions and stroke widths).

irrwahn commented 3 years ago

Sounds like a reasonable feature. I'll look into it, but it will probably take me a few days before I get to it.

qgustavor commented 3 years ago

I tried implementing it myself but as I have zero experience with C I'm sure I made a mess. A snippet:

// inside emitf
r = emit( "%s ", ftoa( buf, config.ass_fprec, v.x * pow(2, config.ass_scale - 1) ) );
r = emit( "%s",  ftoa( buf, config.ass_fprec, v.y * pow(2, config.ass_scale - 1) ) );

I will update svg2ass-gui with this feature as an experimental feature then, when you implement it, I will update it again.

Edit: it's already implemented in the website.

irrwahn commented 3 years ago

I added two experimental options: -p n only affects the \p# tag -s n additionally scales up the coordinates by 2^(n-1) This is not thoroughly tested, please give it a try.

qgustavor commented 3 years ago

Seems it works fine. For some reason when I was testing Aegisub was rendering \p3 and \p4 drawings larger, but when I changed subtitles provider it returned to normal. I think that happened because I used an old Aegisub build, when I tried it again with a new build (from a fork) it worked fine.

I already updated the GUI with the new code. Your code was way better than mine: using 1U << (config.ass_scale_exp - 1) and vec_scal is way cleaner, easier to understand, safer and performant.

irrwahn commented 3 years ago

Good to hear it works in general. I wonder about the Aegisub build. Do you happen to have some version numbers to share, working vs. not working?

qgustavor commented 3 years ago

Aegisub r8942 is the one that had issues. Aegisub 9212 Daydream Cafe was the one that worked fine.

irrwahn commented 3 years ago

Thank you for the info. For the record: r8982 (to be exact commit 293673fef in the official sources plus an unrelated pulseaudio patch) works fine on Linux.