asciinema / agg

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

Weird Chinese rendering #25

Open liblaf opened 1 year ago

liblaf commented 1 year ago

When I use Chinese in terminal it looks fine like this

image

But when I render it as a gif using agg , the Chinese becomes weird

agg --renderer resvg --font-dir "${HOME}/.local/share/fonts/MesloLGS NF" --font-family "MesloLGS NF" demo.cast demo.gif

demo

If I use fontdb as renderer, then Chinese will not be displayed.

a2659802 commented 1 year ago

see also https://github.com/asciinema/agg/issues/10

dlf412 commented 1 year ago

you can edit cast file: add a space character as placeholder after all chinese characters

zetako commented 1 year ago

you can edit cast file: add a space character as placeholder after all chinese characters

This works well! Thanks! I'm using a perl command to convert it now.

(It should be a sed cmd for general usage, but I'm having trouble making sed support unicode)

cat demo.cast | perl -CS -pe 's/([\x{4e00}-\x{9fa5}]|[\x{3040}-\x{30ff}])/$1 /g' > demo.space.cast

The first part (\u4e00-\u9fa5) matches basic CJKs and second part (\u3040-\u30ff) matches japanese kanas. These seems enough for me, check wiki if u need other blocks.

hustcer commented 7 months ago

@zetako Works for me, thanks