wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.91k stars 805 forks source link

Re-consider SVG support for imgcat #6042

Open LitoMore opened 2 months ago

LitoMore commented 2 months ago

I just read the previous discussion on #896. iTerm2 does support SVG images, but not exactly.

iTerm2 cannot parse those SVG images with decimal numbers, such as viewBox="0 0 1.5 2", width="20.5", and height="1.333333".

But for integer sizes, it works well.

Here are some examples on iTerm2 (it uses this imgcat):

imgcat -u 'https://cdn.simpleicons.org/wezterm'
imgcat -u 'https://cdn.simpleicons.org/wezterm?viewbox=auto'
imgcat -u 'https://cdn.simpleicons.org/wezterm?viewbox=auto&size=48'

This means users can insert their own favorite tech/social icons into terminal:

echo "$(imgcat -u 'https://cdn.simpleicons.org/wezterm?viewbox=auto&size=32') My favorite terminal emualtor"

What do you think?


Update

I also made a new approach with icon font. See this discussion below:

tbung commented 2 months ago

You could do something like

Screenshot from 2024-09-06 21-16-05

magick -background None <(wget -q -O- 'https://cdn.simpleicons.org/wezterm?viewbox=auto&size=32') png:- | wezterm imgcat

in the mean time.

wez commented 2 months ago

The other technical concerns I raised on the earlier issue still also apply.

I don't think that wezterm's terminal emulation layer should have an embedded SVG rasterizer for a variety of reasons; the biggest is that svg has a large and complex implementation that is difficult to support fully, and will be a source of issues and support burden for me when someone inevitably complains about discrepancies in rasterization (I get enough of those already for the main terminal functionality!), or represent an increased attack surface if someone comes up with some kind of malicious svg payload.

Aside from being less convenient, I see no real issue with requiring the user to translate the SVG to one of the many widely used and supported bitmap formats with other available utilities that are designed for that purpose.