summaryrefslogtreecommitdiff
path: root/pkgs/by-name/no/noto-fonts/package.nix
blob: 835dac1f2c406bc43a02171858b3fd1a68b21257 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
  lib,
  stdenvNoCC,
  fetchFromGitHub,
  gitUpdater,
  nixosTests,
  variants ? [ ],
  suffix ? "",
  longDescription ? ''
    When text is rendered by a computer, sometimes characters are
    displayed as “tofu”. They are little boxes to indicate your device
    doesn’t have a font to display the text.
    Google has been developing a font family called Noto, which aims to
    support all languages with a harmonious look and feel. Noto is
    Google’s answer to tofu. The name noto is to convey the idea that
    Google’s goal is to see “no more tofu”.  Noto has multiple styles and
    weights, and freely available to all.
  '',
}:

stdenvNoCC.mkDerivation rec {
  pname = "noto-fonts${suffix}";
  version = "2025.04.01";

  src = fetchFromGitHub {
    owner = "notofonts";
    repo = "notofonts.github.io";
    rev = "noto-monthly-release-${version}";
    hash = "sha256-xR3P6RWb1pHdOuCbb+kQXqv3Ip3+2yXAVqeZ+f2M3VU=";
  };

  outputs = [
    "out"
    "megamerge" # Experimental fonts created by mergeing regular notofonts
  ];

  _variants = map (variant: builtins.replaceStrings [ " " ] [ "" ] variant) variants;

  installPhase =
    ''
      # We check availability in order of variable -> otf -> ttf
      # unhinted -- the hinted versions use autohint
      # maintaining maximum coverage.
      #
      # We have a mix of otf and ttf fonts
      local out_font=$out/share/fonts/noto

      install -m444 -Dt $megamerge/share/fonts/truetype/ megamerge/*.ttf
    ''
    + (
      if _variants == [ ] then
        ''
          for folder in $(ls -d fonts/*/); do
            if [[ -d "$folder"unhinted/variable-ttf ]]; then
              install -m444 -Dt $out_font "$folder"unhinted/variable-ttf/*.ttf
            elif [[ -d "$folder"unhinted/otf ]]; then
              install -m444 -Dt $out_font "$folder"unhinted/otf/*.otf
            else
              install -m444 -Dt $out_font "$folder"unhinted/ttf/*.ttf
            fi
          done
        ''
      else
        ''
          for variant in $_variants; do
            if [[ -d fonts/"$variant"/unhinted/variable-ttf ]]; then
              install -m444 -Dt $out_font fonts/"$variant"/unhinted/variable-ttf/*.ttf
            elif [[ -d fonts/"$variant"/unhinted/otf ]]; then
              install -m444 -Dt $out_font fonts/"$variant"/unhinted/otf/*.otf
            else
              install -m444 -Dt $out_font fonts/"$variant"/unhinted/ttf/*.ttf
            fi
          done
        ''
    );

  passthru.updateScript = gitUpdater {
    rev-prefix = "noto-monthly-release-";
  };

  passthru.tests = { inherit (nixosTests) noto-fonts; };

  meta = {
    description = "Beautiful and free fonts for many languages";
    homepage = "https://www.google.com/get/noto/";
    inherit longDescription;
    license = lib.licenses.ofl;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [
      mathnerd314
      emily
      jopejoe1
    ];
  };
}