about summary refs log tree commit diff
path: root/nixpkgs/pkgs/data/fonts/noto-fonts/default.nix
blob: 1acc2abfcc88acfca760a60a83d512cba985f7d6 (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{ stdenv, fetchzip, fetchFromGitHub, optipng, cairo, pythonPackages, pkgconfig, pngquant, which, imagemagick }:

let
  mkNoto = { name, weights, sha256, }:
    let
      version = "2018-11-30";
      ref = "85e78f831469323c85847e23f95026c894159135";
    in
    fetchzip {
      name = "${name}-${version}";
      inherit sha256;
      url = "https://github.com/googlei18n/noto-fonts/archive/${ref}.zip";
      postFetch = ''
        unzip $downloadedFile
        mkdir -p $out/share/fonts/noto
        # Also copy unhinted & alpha fonts for better glyph coverage,
        # if they don't have a hinted version
        # (see https://groups.google.com/d/msg/noto-font/ZJSkZta4n5Y/tZBnLcPdbS0J)
        for ttf in noto-fonts-*/{hinted,unhinted,alpha}/*-${weights}.ttf
        do
            cp -n "$ttf" -t "$out/share/fonts/noto"
        done
      '';
      meta = with stdenv.lib; {
        inherit version;
        description = "Beautiful and free fonts for many languages";
        homepage = https://www.google.com/get/noto/;
        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.

          This package also includes the Arimo, Cousine, and Tinos fonts.
        '';
        license = licenses.asl20;
        platforms = platforms.all;
        maintainers = with maintainers; [ mathnerd314 ];
      };
    };
in

{
  noto-fonts = mkNoto {
    name = "noto-fonts";
    weights = "{Regular,Bold,Light,Italic,BoldItalic,LightItalic}";
    sha256 = "0kvq5ldip2ra2njlxg9fxj46nfqzq5l3n359d3kwfbsld7hixm2d";
  };
  noto-fonts-extra = mkNoto {
    name = "noto-fonts-extra";
    weights = "{Black,Condensed,Extra,Medium,Semi,Thin}*";
    sha256 = "0l94aiy1b3qirg2mmbagbr0014vqk32za79pzck1acy2hgy716kq";
  };
  noto-fonts-cjk = let version = "2.001"; in fetchFromGitHub rec {
    name = "noto-fonts-cjk-${version}";

    # Same as https://noto-website.storage.googleapis.com/pkgs/NotoSansCJK.ttc.zip but versioned & with no extra SIL license file
    owner = "googlei18n";
    repo = "noto-cjk";
    rev = "NotoSansV${version}";

    postFetch = ''
      mkdir -p $out/share/fonts/noto
      tar xOf $downloadedFile noto-cjk-${rev}/NotoSansCJK.ttc.zip |
          funzip > $out/share/fonts/noto/NotoSansCJK.ttc
    '';
    sha256 = "1r2wlw4vmrf2vlwhgjfvndlq1bj4ys5jzspmv6cz5cg3hpqqf528";

    meta = with stdenv.lib; {
      inherit version;
      description = "Beautiful and free fonts for CJK languages";
      homepage = https://www.google.com/get/noto/help/cjk/;
      longDescription =
      ''
        Noto Sans CJK is a sans serif typeface designed as an intermediate style
        between the modern and traditional. It is intended to be a multi-purpose
        digital font for user interface designs, digital content, reading on laptops,
        mobile devices, and electronic books. Noto Sans CJK comprehensively covers
        Simplified Chinese, Traditional Chinese, Japanese, and Korean in a unified font
        family. It supports regional variants of ideographic characters for each of the
        four languages. In addition, it supports Japanese kana, vertical forms, and
        variant characters (itaiji); it supports Korean hangeul — both contemporary and
        archaic.
      '';
      license = licenses.ofl;
      platforms = platforms.all;
      maintainers = with maintainers; [ mathnerd314 ];
    };
  };
  noto-fonts-emoji = let version = "2018-08-10-unicode11"; in stdenv.mkDerivation {
    pname = "noto-fonts-emoji";
    inherit version;

    src = fetchFromGitHub {
      owner = "googlei18n";
      repo = "noto-emoji";
      rev = "v${version}";
      sha256 = "1y54zsvwf5pqhcd9cl2zz5l52qyswn6kycvrq03zm5kqqsngbw3p";
    };

    buildInputs = [ cairo ];
    nativeBuildInputs = [ pngquant optipng which cairo pkgconfig imagemagick ]
                     ++ (with pythonPackages; [ python fonttools nototools ]);

    postPatch = ''
      sed -i 's,^PNGQUANT :=.*,PNGQUANT := ${pngquant}/bin/pngquant,' Makefile
      patchShebangs flag_glyph_name.py
    '';

    enableParallelBuilding = true;

    installPhase = ''
      mkdir -p $out/share/fonts/noto
      cp NotoColorEmoji.ttf fonts/NotoEmoji-Regular.ttf $out/share/fonts/noto
    '';

    meta = with stdenv.lib; {
      inherit version;
      description = "Color and Black-and-White emoji fonts";
      homepage = https://github.com/googlei18n/noto-emoji;
      license = with licenses; [ ofl asl20 ];
      platforms = platforms.all;
      maintainers = with maintainers; [ mathnerd314 ];
    };
  };
}