asciinema / agg

asciinema gif generator
Apache License 2.0
1.11k stars 38 forks source link

Nerd Font icons are not displayed #64

Open qgrp-m-kondratenko opened 6 months ago

qgrp-m-kondratenko commented 6 months ago

Describe the bug When rendering the cast containing icons from Nerd Fonts, the icons are not displayed in the resulting gif.

To Reproduce Steps to reproduce the behavior:

  1. Create /tmp/test.cast from test.zip. It contains a recording of bash shell that uses starship with Nerd Font icons.
  2. View the recording with ascinema play /tmp/test.cast. Nerd Font icons are displayed properly. play
  3. Generate gif agg --font-family 'FiraCode Nerd Font' /tmp/test.cast /tmp/out.gif.
  4. View the gif firefox /tmp/out.gif.
  5. See the missing icons. out

Expected behavior Icons are supposed to be visible the same way as when using ascinema play /tmp/test.cast

Versions:

Additional Context:

agg -vvv --font-family 'FiraCode Nerd Font' /tmp/test.cast /tmp/out.gif
[INFO  agg] terminal size: 135x34
[INFO  agg] selected font families: ["FiraCode Nerd Font"]
[INFO  agg] selected theme: dracula
[DEBUG agg::renderer::fontdue] looking up font for families=["FiraCode Nerd Font"], weight=400, style=Normal
[DEBUG agg::renderer::fontdue] found font with id=ID(380)
[INFO  agg] gif dimensions: 1180x686
[DEBUG agg::renderer::fontdue] looking up font for families=["FiraCode Nerd Font"], weight=700, style=Normal
[DEBUG agg::renderer::fontdue] found font with id=ID(440)
[DEBUG agg::renderer::fontdue] looking up font for families=["FiraCode Nerd Font"], weight=400, style=Normal
[DEBUG agg::renderer::fontdue] found font with id=ID(380)
2 / 2 [======] 100.00 % 5.05/s [INFO  agg] rendering finished in 0.39664295s
ku1ik commented 4 months ago

I see that the branch icon (between "on" and "main") is rendered correctly, so that means the Nerd Font is loaded and used fine.

The package and duck icons are emojis. agg doesn't support color emojis, but you can have monochrome emojis rendered with Noto Emoji font as explained here.

So the most of this is expected and working as intended. The only thing which I'm not sure about is the missing up arrow after the $ sign... It's not an emoji, so should have rendered with FiraCode Nerd Font. Can you try with another Nerd Font, e.g. JetBrains Mono?

qgrp-m-kondratenko commented 4 months ago

@ku1ik Changing the font to "JetBrainsMono NF" produced the exact same result. However changing the renderer to "--renderer resvg" more or less fixed the issue for both fonts. The icons are displayed, just not the way they are displayed in the terminal.

agg -vvv --font-family 'FiraCode Nerd Font' --renderer resvg test.cast out.gif
[INFO  agg] terminal size: 135x34
[INFO  agg] selected font families: ["FiraCode Nerd Font"]
[INFO  agg] selected theme: dracula
[INFO  agg] gif dimensions: 1151x686
[WARN  usvg_text_layout] Fallback from FiraCode Nerd Font to Symbola.
[WARN  usvg_text_layout] Fallback from FiraCode Nerd Font to Symbola.
[WARN  usvg_text_layout] Fallback from FiraCode Nerd Font to Symbola.
2 / 2 [===============================] 100.00 % 13.56/s [INFO  agg] rendering finished in 0.14776781s

out