New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/fontconfig: Allow setting default emoji font #67667
Conversation
cc @vcunat @ttuegel (#9110 (comment)) re |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested using #67522 which adds the noto font default for gnome3 and the following configuration
fonts.fonts = [ pkgs.joypixels ];
fonts.fontconfig.defaultFonts.emoji = ["JoyPixels"];
(note penultimate has to be disabled for this to work properly)
And fc-match --verbose "Emoji"
shows that JoyPixels
was matched. ✔️
cc @volth (perhaps could be helpful as well) |
Moved JoyPixels before EmojiOne as per https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/67#note_216169. |
Added a test, which depends on #67529. And apparently it does not work with TwEmoji, even though it work with JoyPixels just fine: --- a/nixos/tests/fontconfig-default-fonts.nix
+++ b/nixos/tests/fontconfig-default-fonts.nix
@@ -8,6 +8,7 @@ import ./make-test.nix ({ lib, ... }:
noto-fonts-emoji
cantarell-fonts
twemoji-color-font
+ joypixels
source-code-pro
gentium
];
@@ -15,8 +16,9 @@ import ./make-test.nix ({ lib, ... }:
serif = [ "Gentium Plus" ];
sansSerif = [ "Cantarell" ];
monospace = [ "Source Code Pro" ];
- emoji = [ "Twitter Color Emoji" ];
+ emoji = [ "JoyPixels" ];
};
+ nixpkgs.config.allowUnfree = true;
};
testScript = ''
@@ -27,6 +29,6 @@ import ./make-test.nix ({ lib, ... }:
$machine->succeed("fc-match serif | grep '\"Gentium Plus\"'");
$machine->succeed("fc-match sans-serif | grep '\"Cantarell\"'");
$machine->succeed("fc-match monospace | grep '\"Source Code Pro\"'");
- $machine->succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'");
+ $machine->succeed("fc-match emoji | grep '\"JoyPixels\"'");
'';
}) At this point, I am tempted to just call it a quits and add a comment that you can only switch between Noto and JoyPixels 😫 |
These are the outputs of matching for each default:
|
Using
|
I guess the main issue is that the Twitter Color Emoji font claims it does not support colours, getting a 1000 score penalty there. Compare it with Noto Color Emoji, which gets 1 in name penalty:
|
Confirmed it works with #67701 |
@GrahamcOfBorg test fontconfig-default-fonts |
Yay, we still need #67529 or tests will fail. |
3896f89
to
8ccfffc
Compare
Got a good consensus on #67529 during office-hours today. |
@GrahamcOfBorg test fontconfig-default-fonts |
So downloading the latest unstable minimal image Firefox said 536 MB. I built the image on this branch and used
Seems fine, think that's the correct check to be doing. |
In fontconfig’s 60-generic.conf, order of preference is estabilished for emoji font family. Because fontconfig parses the config files in lexicographic order, appending each <prefer> from <alias> element to the family’s prefer list (to be prepended before the family) [1], our font family defaults stored in 52-nixos-default-fonts.conf will take precedence. That is, of course, unless the default „weak“ binding [2] is used. Emoji family binds strongly [3], so we need to set binding to “same” for our <alias>es to be considered before the ones from 60-generic.conf. By default, we will set the option to all emoji fonts supported by fontconfig, so that emoji works for user if they have at least one emoji font installed. If they have multiple emoji fonts installed, we will use the fontconfig’s order of preference [4]. [1]: bohoomil/fontconfig-ultimate#51 (comment) [2]: https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#AEN25 [3]: https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/cc8442dec85e9d416436d19eeae1783f2d3008f0 [4]: https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/c41c9220181b203d1cf1f6435f6e3735cb7c84ac
Make sure the fonts.enableDefaultFonts option works.
These days, emoji are ubiqitous so we need to add emoji font.
e071dad
to
fcec3ff
Compare
Rebase as the release notes are quickly getting conflicts. |
In fontconfig’s
60-generic.conf
, order of preference is established for emoji font family. Because fontconfig parses the config files in lexicographic order, appending each<prefer>
from<alias>
element to the family’s prefer list (to be prepended before the family) 1, our font family defaults stored in52-nixos-default-fonts.conf
will take precedence. That is, of course, unless the defaultweak
binding 2 is used. Emoji family binds strongly 3, so we need to set binding tosame
for our<alias>
es to be considered before the ones from60-generic.conf
.By default, we will set the option to all emoji fonts supported by fontconfig, so that emoji works for user if they have at least one emoji font installed. If they have multiple emoji fonts installed, we will use the fontconfig’s order of preference 4.
Blocking PRs
Related PRs