asciinema / agg

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

Doesn't render unicode characters such as β€œπŸ€–β€ (U+1F916) and β€œβ Έβ€ ? #28

Closed ahmetkca closed 1 year ago

ahmetkca commented 1 year ago

I have a cli application with spinner and I also use some unicode characters such as β€œπŸ€–β€ (U+1F916) and β€œβ Έβ€œ. They show up as outline rectangles instead. I have also tried to use Nerd Font by specify custom --font-dir and --font-family

ahmetkca commented 1 year ago

I have tried resvg renderer instead of fontdue and it was able to render β€œβ Έβ€œ and it didn't render anything for β€œπŸ€–β€ at all.

I think the problem is with the renderer. I don't know maybe there is a better renderer?

ku1ik commented 1 year ago

Can you provide example .cast file so we can try to reproduce the problem? Also, what OS?

Zhengqbbb commented 1 year ago

maybe can try add option --renderer "resvg"

charlesnicholson commented 1 year ago

I just hit this too on macOS 13.2.1 on a 2022 M2 MacBook Pro:

Expected: improg-expected

Actual (no options): improg-bad-agg

Actual (--render "resvg"): improg-bad-agg-resvg

I'm happy to share the cast file but GitHub doesn't allow the ".cast" file type as an attachment; how would you like to receive it? Alternately, if it's easier, my terminal app is trivial to reproduce, just clone and run make and then ./build/demo: https://github.com/charlesnicholson/improg. It has some whitespace bugs on Linux and Windows but at least the emoji do render :)

charlesnicholson commented 1 year ago

I just discovered the --font-family flag, and they fix the display of the unicode characters in my prompt, but the 2-column emoji are all still broken. This happens with and without the --renderer resvg flag.

./agg-aarch64-apple-darwin --renderer resvg --font-family "Hack Nerd Font" improg-bad.cast improg.gif
ku1ik commented 1 year ago

I've just released 1.4.0 with much improved font loading and rendering behaviour. Please give it a try. Also see new Fonts section in README.

issue-28

charlesnicholson commented 1 year ago

Thanks for the quick update! Unfortunately I'm not seeing any improvements for the various emoji (U+1F6..). With agg built from the 1.4.0 tag:

../agg/target/release/agg improg.cast improg.gif --font-family "MesloLGS NF" --renderer resvg improg resvg

../agg/target/release/agg improg.cast improg.gif --font-family "MesloLGS NF" improg

Here's a screen grab from my terminal as the demo is running:

Screenshot 2023-03-30 at 9 21 54 AM

Here's the cast file I'm using. improg.cast.zip

Perhaps it has something to do with my font? I'm using a nerd-patched Meno: https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Meslo/M/Regular/complete/Meslo%20LG%20M%20Regular%20Nerd%20Font%20Complete.ttf

ku1ik commented 1 year ago

@charlesnicholson See Fonts section in README for info on emoji support. Without Noto Emoji font on your system you won't get any emoji rendered.

charlesnicholson commented 1 year ago

Ah, thanks, gotcha. Should I open another ticket for supporting colored emoji with the user's font?

ku1ik commented 1 year ago

As for color emojis - agg uses fontdue library in its default renderer backend and this lib doesn't yet support color fonts. See https://github.com/mooman219/fontdue/issues/47 . Once fontdue adds support for it, e.g. for Noto Color Emoji as mentioned in that issue, we'll have it in agg.

We also have this alternative SVG based renderer - resvg - but similarly, it can't deal with color emoji properly yet. See https://github.com/RazrFalcon/resvg/issues/485#issuecomment-982854419

In other words, you could open a ticket but I don't plan to look into that until either of the libs gets better support for it, or until we write another renderer using a different text rendering library. So it's not really going to happen soon.

charlesnicholson commented 1 year ago

I see, thanks for the response! I've been using https://github.com/icholy/ttygif and it works with whatever the user's font + setup are; I was hoping to move to asciinema but I guess it's not quite there yet :)