Fonts: Difference between revisions

imported>Verhovsky
No edit summary
imported>Verhovsky
No edit summary
Line 23: Line 23:


=== Installing specific fonts from nerdfonts ===
=== Installing specific fonts from nerdfonts ===
You probably want to install some fonts from nerdfonts repository and not the entiere repository (take much time to install all the fonts). To achieve that on stable 20.03, you can use an overlay created by [https://github.com/lightdiscord/nix-nerd-fonts-overlay# LightDiscord]. Here is an example of how to use it:
You probably want to install some fonts from the [https://www.nerdfonts.com/ nerdfonts] repository and not the entire repository (it takes a lot of time to install all the fonts). To achieve that on stable 20.03, you can use an overlay created by [https://github.com/lightdiscord/nix-nerd-fonts-overlay# LightDiscord]. Here is an example of how to use it:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
{
{
   nixpkgs.overlays = [ (import ./nix-nerd-fonts-overlay/default.nix) ]; #Assuming you cloned the repository on the same directory
   nixpkgs.overlays = [ (import ./nix-nerd-fonts-overlay/default.nix) ]; # Assuming you cloned the repository to the same directory
   fonts.fonts = with pkgs; [
   fonts.fonts = with pkgs; [
     nerd-fonts.firacode
     nerd-fonts.firacode
Line 36: Line 36:
</syntaxhighlight>
</syntaxhighlight>


This will cause NixOS to download only fira code, jetbrains mono and droid sans mono fonts from nerd-fonts instead of the whole package.
This will cause NixOS to download only [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode Fira Code], [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/JetBrainsMono Jetbrains Mono] and [https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/DroidSansMono Droid Sans Mono] fonts from [https://github.com/ryanoasis/nerd-fonts nerd-fonts] instead of the whole package.


On unstable however, there's a built-in option that looks like that :  
On unstable however, there's a built-in option that looks like this:  
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{ pkgs, ... }:
Line 51: Line 51:
</syntaxhighlight>
</syntaxhighlight>


This will cause NixOS to download only fira code and droid sans mono fonts from nerd-fonts instead of the whole package.
This will cause NixOS to download only Fira Code and Droid Sans Mono fonts from nerd-fonts instead of the whole package.


=== Imperative installation of user fonts ===
=== Imperative installation of user fonts ===
Line 66: Line 66:


=== Set multiple fonts for different languages ===
=== Set multiple fonts for different languages ===
If you are not a native English speaker and want to use another languages alongside English, you may want to set appropriate fonts for each language in your whole OS. In NixOS, it's so easy. Imagine I'm a Persian speaker and I want to set "Vazir" font to Persian texts and "Ubuntu" font for English texts. Just put these lines into your configuration.nix:
If you want to use other languages alongside English, you may want to set appropriate fonts for each language in your whole OS. For example, a Persian speaker might want to use the [https://rastikerdar.github.io/vazir-font/ Vazir] font for Persian texts and the [https://design.ubuntu.com/font/ Ubuntu] font for English texts. Just put these lines into your <code>configuration.nix</code>:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 103: Line 103:
=== Adding personal fonts to <code>~/.fonts</code> doesn't work ===
=== Adding personal fonts to <code>~/.fonts</code> doesn't work ===


The <code>~/.fonts</code> is being deprecated upstream<ref>https://lists.freedesktop.org/archives/fontconfig/2014-July/005269.html</ref>. It already is not working with NixOS.  
The <code>~/.fonts</code> directory is being deprecated upstream<ref>https://lists.freedesktop.org/archives/fontconfig/2014-July/005269.html</ref>. It already doesn't work in NixOS.  


The new preferred location is in <code>$XDG_DATA_HOME/fonts</code>, which for most users will resolve to <code>~/.local/share/fonts</code><ref>https://lists.freedesktop.org/archives/fontconfig/2014-July/005270.html</ref>
The new preferred location is in <code>$XDG_DATA_HOME/fonts</code>, which for most users will resolve to <code>~/.local/share/fonts</code><ref>https://lists.freedesktop.org/archives/fontconfig/2014-July/005270.html</ref>


<hr />
<hr />