@@ -0,0 +1,122 @@
1+# Based upon https://src.fedoraproject.org/rpms/twitter-twemoji-fonts/tree/454acad50ba584d9602ccd4238fc5e585abc15c9
2+# The main difference is that we use “Twitter Color Emoji” name (which is recognized by upstream fontconfig)
3+
4+{ stdenv
5+, fetchFromGitHub
6+, cairo
7+, imagemagick
8+, pkg-config
9+, pngquant
10+, python2
11+, which
12+, zopfli
13+}:
14+
15+let
16+ version = "12.1.2";
17+
18+ # Cannot use noto-fonts-emoji.src since it is too old
19+ # and still tries to use vendored pngquant.
20+ notoSrc = fetchFromGitHub {
21+ name = "noto";
22+ owner = "googlefonts";
23+ repo = "noto-emoji";
24+ rev = "833a43d03246a9325e748a2d783006454d76ff66";
25+ sha256 = "1g6ikzk8banm3ihqm9g27ggjq2mn1b1hq3zhpl13lxid6mp60s4a";
26+ };
27+
28+ twemojiSrc = fetchFromGitHub {
29+ name = "twemoji";
30+ owner = "twitter";
31+ repo = "twemoji";
32+ rev = "v${version}";
33+ sha256 = "0vzmlp83vnk4njcfkn03jcc1vkg2rf12zf5kj3p3a373xr4ds1zn";
34+ };
35+
36+ python = python2.withPackages (pp: with pp; [
37+ nototools
38+ ]);
39+in
40+stdenv.mkDerivation rec {
41+ pname = "twitter-color-emoji";
42+ inherit version;
43+
44+ srcs = [
45+ notoSrc
46+ twemojiSrc
47+ ];
48+
49+ sourceRoot = notoSrc.name;
50+
51+ postUnpack = ''
52+ chmod -R +w ${twemojiSrc.name}
53+ mv ${twemojiSrc.name} ${notoSrc.name}
54+ '';
55+
56+ nativeBuildInputs = [
57+ cairo
58+ imagemagick
59+ pkg-config
60+ pngquant
61+ python
62+ which
63+ zopfli
64+ ];
65+
66+ postPatch = let
67+ templateSubstitutions = stdenv.lib.concatStringsSep "; " [
68+ ''s#Noto Color Emoji#Twitter Color Emoji#''
69+ ''s#NotoColorEmoji#TwitterColorEmoji#''
70+ ''s#Copyright .* Google Inc\.#Twitter, Inc and other contributors.#''
71+ ''s# Version .*# ${version}#''
72+ ''s#.*is a trademark.*##''
73+ ''s#Google, Inc\.#Twitter, Inc and other contributors#''
74+ ''s#http://www.google.com/get/noto/#https://twemoji.twitter.com/#''
75+ ''s#.*is licensed under.*# Creative Commons Attribution 4.0 International#''
76+ ''s#http://scripts.sil.org/OFL#http://creativecommons.org/licenses/by/4.0/#''
77+ ];
78+ in ''
79+ patchShebangs ./flag_glyph_name.py
80+
81+ sed '${templateSubstitutions}' NotoColorEmoji.tmpl.ttx.tmpl > TwitterColorEmoji.tmpl.ttx.tmpl
82+ pushd ${twemojiSrc.name}/assets/72x72/
83+ for png in *.png; do
84+ mv $png emoji_u''${png//-/_}
85+ done
86+ popd
87+ '';
88+
89+ makeFlags = [
90+ "EMOJI=TwitterColorEmoji"
91+ "EMOJI_SRC_DIR=${twemojiSrc.name}/assets/72x72"
92+ "BODY_DIMENSIONS=76x72"
93+ ];
94+
95+ enableParallelBuilding = true;
96+
97+ installPhase = ''
98+ install -Dm644 TwitterColorEmoji.ttf $out/share/fonts/truetype/TwitterColorEmoji.ttf
99+ '';
100+
101+ meta = with stdenv.lib; {
102+ description = "Color emoji font with a flat visual style, designed and used by Twitter";
103+ longDescription = ''
104+ A bitmap color emoji font built from the Twitter Emoji for
105+ Everyone artwork with support for ZWJ, skin tone diversity and country
106+ flags.
107+
108+ This font uses Google’s CBDT format making it work on Android and Linux graphical stack.
109+ '';
110+ homepage = "https://twemoji.twitter.com/";
111+ # In noto-emoji-fonts source
112+ ## noto-emoji code is in ASL 2.0 license
113+ ## Emoji fonts are under OFL license
114+ ### third_party color-emoji code is in ASL 2.0 license
115+ ### third_party region-flags code is in Public Domain license
116+ # In twemoji source
117+ ## Artwork is Creative Commons Attribution 4.0 International
118+ ## Non-artwork is MIT
119+ license = with licenses; [ asl20 ofl cc-by-40 mit ];
120+ maintainers = with maintainers; [ jtojnar ];
121+ };
122+}