asciinema/agg

--font-family "CaskaydiaCove Nerd Font" - not found (locally installed, personal fonts problem?)

shoffmeister opened this issue · 8 comments

When invoking agg --font-family "CaskaydiaCove Nerd Font" starship.cast starship.cast.gif, I get Error: no faces matching font family CaskaydiaCove Nerd Font

"CaskaydiaCove Nerd Font" is, effectively, the Cascadia Console font - downloaded enriched as a nerd font from https://www.nerdfonts.com/font-downloads

This has been installed as a personal font on my KDE Plasma 5.25 desktop (Fedora 36); physically this font and its siblings live in ~/.fonts/c, as

~/.fonts/c 
❯ ll
total 151324
-rw-r--r-- 1 stefan stefan 2435640 Sep 26 09:40 Caskaydia_Cove_Nerd_Font_Complete_Bold_Italic.otf
-rw-r--r-- 1 stefan stefan 2624736 Sep 26 09:40 Caskaydia_Cove_Nerd_Font_Complete_Bold.otf
-rw-r--r-- 1 stefan stefan 2428652 Sep 26 09:40 Caskaydia_Cove_Nerd_Font_Complete_ExtraLight_Italic.otf
-rw-r--r-- 1 stefan stefan 2607260 Sep 26 09:40 Caskaydia_Cove_Nerd_Font_Complete_ExtraLight.otf
-rw-r--r-- 1 stefan stefan 2437340 Sep 26 09:40 Caskaydia_Cove_Nerd_Font_Complete_Italic.otf

Is this a case of these fonts being installed as personal fonts?

Version affected is

agg --version
agg 1.3.0

compiled from source (43977bf, 2022-09-17).

Somehow I managed to miss the --font-dir option; agg --font-dir "${HOME}/.fonts" --font-family "CaskaydiaCove Nerd Font" starship.cast starship.cast.gif works.

Perhaps it makes sense to add {$HOME}/.fonts as a default font directory?

Incidentally, /etc/fonts/fonts.conf contains, among other settings,

<!-- Font directory list -->

        <dir>/usr/share/fonts</dir>
        <dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
        <dir prefix="xdg">fonts</dir>
        <!-- the following element will be removed in the future -->
        <dir>~/.fonts</dir>

Perhaps fontdb (https://crates.io/crates/fontdb) parsing of font configuration does not the right thing? (just going by poking on the agg sources)

same:
my font word "❯" (unicode) can't show

@shoffmeister sorry to bother you, but how did you manage to make it work using Nerd Fonts?

This is my closest try:

❯ agg --theme asciinema --font-dir "/usr/local/share/fonts" --font-family "JetBrains Mono Nerd Font" --fps-cap 60 --font-size 21 /tmp/tmpznwgyw6l-ascii.cast --renderer resvg output.gif
Error: no faces matching font family JetBrains Mono Nerd Font

Raw command:

agg --theme asciinema --font-dir "/usr/local/share/fonts" --font-family "JetBrains Mono Nerd Font" --fps-cap 60 --font-size 21 /tmp/tmpznwgyw6l-ascii.cast --renderer resvg output.gif

This is contents of /usr/local/share/fonts:

❯ ls -R -1 /usr/local/share/fonts

/usr/local/share/fonts/j:
JetBrains_Mono_Bold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_Bold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Bold_Nerd_Font_Complete.ttf
JetBrains_Mono_Bold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_ExtraBold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_ExtraBold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_ExtraBold_Nerd_Font_Complete.ttf
JetBrains_Mono_ExtraBold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_ExtraLight_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_ExtraLight_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_ExtraLight_Nerd_Font_Complete.ttf
JetBrains_Mono_ExtraLight_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Light_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_Light_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Light_Nerd_Font_Complete.ttf
JetBrains_Mono_Light_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Medium_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_Medium_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Medium_Nerd_Font_Complete.ttf
JetBrains_Mono_Medium_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Bold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Bold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Bold_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Bold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_ExtraBold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_ExtraBold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_ExtraBold_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_ExtraBold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_ExtraLight_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_ExtraLight_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_ExtraLight_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_ExtraLight_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Light_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Light_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Light_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Light_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Medium_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Medium_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Medium_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Medium_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Regular_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Regular_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_SemiBold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_SemiBold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_SemiBold_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_SemiBold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Thin_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Thin_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_NL_Thin_Nerd_Font_Complete.ttf
JetBrains_Mono_NL_Thin_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Regular_Nerd_Font_Complete.ttf
JetBrains_Mono_Regular_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_SemiBold_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_SemiBold_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_SemiBold_Nerd_Font_Complete.ttf
JetBrains_Mono_SemiBold_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Thin_Italic_Nerd_Font_Complete.ttf
JetBrains_Mono_Thin_Italic_Nerd_Font_Complete_Mono.ttf
JetBrains_Mono_Thin_Nerd_Font_Complete.ttf
JetBrains_Mono_Thin_Nerd_Font_Complete_Mono.ttf

JetBrainsMono.zip downloaded from here installed for the system using KDE font management. I removed fonts with Windows in the name because I use endeavourOS.

Do you have any idea, what am I doing wrong?

Update — this works:

agg --theme asciinema --font-family "JetBrainsMono Nerd Font" --fps-cap 60 --font-size 21 --renderer resvg demo.cast output.gif

I checked the name inside my LibreOffice Writer.

same: my font word "❯" (unicode) can't show

add --renderer "resvg" resolved

I find compatibility will be better and not many issues with resvg

ku1ik commented

Both renderers, default fontdue and the alternative resvg, use the same font loading code so there should be no difference in font loading whatsoever. Are you sure --renderer "resvg" fixed it, or maybe you change something else at the same time?

Both renderers, default fontdue and the alternative resvg use the same font loading code so there should be no difference in font loading whatsoever. Are you sure --renderer "resvg" fixed it, or maybe you change something else at the same time?

Not modify other information, I just want to display font word "❯" (unicode) you can have try.
fontdue NO, resvg YES

But gif generated by using resvg will be a little blurry, I don't know how to deal with it

ku1ik commented

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.

The problem of fonts in ~/.fonts not being used was in one of the dependencies, fontdb, which is now fixed by bumping this dep to newer version.

As for ❯ symbol - font fallback mechanism is now fixed and it should properly render it as long as one of the fonts in a default font-family list has this glyph, or you have DejaVu Sans font installed. This now works with default renderer (fontdue) as well.