Open Dioprz opened 4 months ago
It will be because google-fonts is installing the COLRv1 version of the NotoEmoji. As far as I can tell this doesnt render in FreeType, at all. Attached is a simple C program to demonstrate.
#define FONT_PATH "/t/Noto-COLRv1.ttf"
#define CHARACTER 0x1f600
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
int main() {
FT_Library ft;
if (FT_Init_FreeType(&ft)) {
fprintf(stderr, "Could not init freetype library\n");
return 1;
}
FT_Face face;
if (FT_New_Face(ft, FONT_PATH, 0, &face)) {
fprintf(stderr, "Could not open font\n");
FT_Done_FreeType(ft);
return 1;
}
FT_Set_Char_Size(face, 0, 48 * 64, 300, 300);
FT_UInt glyph_index = FT_Get_Char_Index(face, CHARACTER);
FT_Bitmap* bitmap = &face->glyph->bitmap;
FT_Color* palette;
FT_LayerIterator iterator = {0};
FT_Bool have_layers;
FT_UInt layer_glyph_index = 0;
FT_UInt layer_color_index = 0;
FT_Error error = FT_Palette_Select( face, 0, &palette );
if ( error ) { return 1; }
have_layers = FT_Get_Color_Glyph_Layer(face, glyph_index, &layer_glyph_index, &layer_color_index, &iterator);
printf("COLR information: have_layers: %d num_layers: %d\n", have_layers, iterator.num_layers);
return 0;
}
Change the FONT_PATH at the top to the path to the NOTO ttf. Run with:
gcc -I/usr/include/freetype2 ft.c -o ft -lfreetype && ./ft
See output:
COLR information: have_layers: 0 num_layers: 0
FreeType thinks the glyph has no color layers when using the COLRv1 font and thus renders it blank.
And for reference: https://github.com/kovidgoyal/kitty/issues/7140
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/emojis-not-showing-in-kitty/51294/4
Describe the bug
The installation of the package
google-fonts
breaks emoji usage via the Noto Color Emoji font in Kitty.Steps To Reproduce
Steps to reproduce the behavior using home-manager:
In
home.nix
and add
google-fonts
in your installed packages.After make a home switch, launch
kitty --debug-font-fallback
and copy paste any emoji from the web. You will get an ending message like this one:And your pasted emoji will look like this (Yes, you can't see it.)
Now, remove
google-fonts
from your packages, and installnoto-fonts-color-emoji
andnoto-fonts
. Make the home switch, and launch againkitty --debug-font-fallback
. Copy-paste the emoji, and now the emoji is visible and works as expected. What is more, you can see in the ending logs something like this:Please notice the differences between the font used (NotoColorEmoji vs NotoColorEmoji-Regular), as well as the parameters used on each one.
Expected behavior
Install
google-fonts
shouldn't break emoji usage.Additional context
Workarounds:
google-fonts
package, just use the configuration on the step 3.google-fonts
package, then addWarning: In some cases (I'm not sure when/why), even having the correct configuration (step 3), you can end with emojis looking like this:
.
Try using the command
fc-cache -f
and check everything is working again withkitty --debug-font-fallback
.Possibly related:
https://github.com/NixOS/nixpkgs/issues/225541 and https://github.com/NixOS/nixpkgs/issues/230895
Notify maintainers
@manveru
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.