marionebl / svg-term-cli

Share terminal sessions via SVG and CSS
MIT License
3.48k stars 116 forks source link

Preserving aspect ratio #33

Open imrek opened 6 years ago

imrek commented 6 years ago

I have multiple issues, but all center around preserving the aspect ratio when I convert an asciicast file to an .svg.

I have been experimenting with the flags but I'm not sure what solves this problem.

I use gnome-terminal on Ubuntu 16.04. I would like to get output where the width : height ratio is 16 : 9. I've found that the closest cols/rows setting to this is 94 cols and 28 rows given the default font and font-size in gnome-terminal, so accordingly I add --width=94 and --height=28 to the command.

The full command I'm using is:

svg-term --in=htop --out=htop.svg --term=terminal --profile=profile4svgterm.dconf --no-optimize --width=94 --height=28

Unfortunately, the .svg output is rendered with a different aspect ratio.

Here's gnome-terminal running asciinema play htop: screenshot from 2018-05-29 14-39-33

And then the .svg output as displayed by chromium-browser:

screenshot from 2018-05-29 14-36-11

It's probably hard to perceive at first glance, but the .svg output slightly taller and therefore has a different aspect ratio. Also, the characters on the right hand side are slightly cut off, but that probably also happens because of the different ratio.

As I understand, the terminal profile I specify is ignored by svg-term, or I am not specifying it correctly. As of Ubuntu 16.04 the terminal profile is part of dconf, ie. it's not a stand-alone file somewhere in the home directory of the user, but part of a database and can be exported. Here's the file (profile4svgterm.dconf) I get after exporting from dconf.

[/]
foreground-color='rgb(0,255,0)'
visible-name='profile4svgterm'
default-size-columns=94
default-size-rows=28
use-system-font=false
use-theme-colors=false
font='Monospace 12'
use-theme-transparency=false
background-color='rgb(0,0,0)'

I am not sure svg-term understands this file and would like to know what format works the best.

Another, unrelated issue I have noticed that sometimes the .svg output is a file with 0 bytes and therefore the command has to be repeated to get a non-empty output.

Here's a gist with the input and output files.


UPDATE: After doing some troubleshooting, I've found that If I specify a non existing file for --profile, svg-term does not complain about the invalid path/file.

marionebl commented 5 years ago

Sorry for taking so long to respond to this.

I suspect the issues you see might at least partially be caused by svg-term (via. term-schemes) not parsing your --profile correctly.

The expected behavior would be for svg-term-cli to fail loudly (being unable to parse dconf files as the xml expected for --term=terminal), which is not what happens for you if I understand correctly? (Something with the terminal format detection appears to be off...)

svg-term-cli expects you to provide a --terminal flag that indicates the profile format to parse: