agg icon indicating copy to clipboard operation
agg copied to clipboard

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

Open shoffmeister opened this issue 2 years ago • 1 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 (43977bf11493650e76de0c9d4267bf0b4533255b, 2022-09-17).

shoffmeister avatar Sep 26 '22 08:09 shoffmeister

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)

shoffmeister avatar Sep 26 '22 08:09 shoffmeister

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

Zhengqbbb avatar Nov 11 '22 08:11 Zhengqbbb

@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?

Psyhackological avatar Jan 28 '23 14:01 Psyhackological

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.

Psyhackological avatar Jan 28 '23 16:01 Psyhackological

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

add --renderer "resvg" resolved

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

Zhengqbbb avatar Feb 11 '23 16:02 Zhengqbbb

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?

ku1ik avatar Feb 16 '23 16:02 ku1ik

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

Zhengqbbb avatar Feb 17 '23 03:02 Zhengqbbb

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.

ku1ik avatar Mar 30 '23 12:03 ku1ik