2019-10-01 13:43:42 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, scfbuild
|
2020-07-06 10:21:48 +00:00
|
|
|
, python3Packages
|
2019-10-01 13:43:42 +00:00
|
|
|
, variant ? "color" # "color" or "black"
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
filename = builtins.replaceStrings
|
|
|
|
[ "color" "black" ]
|
|
|
|
[ "OpenMoji-Color.ttf" "OpenMoji-Black.ttf" ]
|
|
|
|
variant;
|
2020-07-06 10:21:48 +00:00
|
|
|
scfbuildOptions = stdenv.lib.optionalString (variant == "black") "--glyph-only";
|
|
|
|
|
|
|
|
# We have to use their scfbuild fork:
|
|
|
|
# https://github.com/hfg-gmuend/openmoji/tree/master/font#setup
|
|
|
|
scfbuildPatched = scfbuild.overrideAttrs (old: {
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "b-g";
|
|
|
|
repo = "scfbuild";
|
|
|
|
rev = "880f690332fc9cc4dee0790921d331f13bd5acaa";
|
|
|
|
sha256 = "0d61gn69hgxn17jvs69xpblq9z1l85aymbrn6jjwqamhpcl42c04";
|
|
|
|
};
|
|
|
|
propagatedBuildInputs = old.propagatedBuildInputs ++ [ python3Packages.lxml ];
|
|
|
|
});
|
2019-10-01 13:43:42 +00:00
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "openmoji";
|
2020-07-06 10:21:48 +00:00
|
|
|
version = "12.4.0";
|
2019-10-01 13:43:42 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "hfg-gmuend";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2020-07-06 10:21:48 +00:00
|
|
|
sha256 = "0zis0i7fn7dqv39c9ms7f1p4dqqzwdfwkdgrijaak1cmb8rkn3a0";
|
2019-10-01 13:43:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2020-07-06 10:21:48 +00:00
|
|
|
scfbuildPatched
|
2019-10-01 13:43:42 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Some id and data-* attributes in the svg files contain unicode characters,
|
|
|
|
# which scfbuild (a python2 program) does not like
|
|
|
|
# (https://github.com/13rac1/scfbuild/issues/14).
|
|
|
|
# Fortunately, it's only metadata which we can remove:
|
|
|
|
postPatch = ''
|
|
|
|
sed -Ei 's/(id|data-[^=]*)="[^"]*"//g' black/svg/*.svg color/svg/*.svg
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
# Bash reimplementation of helpers/export-svg-font.js
|
|
|
|
# so we don't need to build all the node deps first
|
|
|
|
hexcodes=()
|
|
|
|
missingGlyphBlack='./black/svg/25A1.svg'
|
|
|
|
missingGlyphColor='./color/svg/25A1.svg'
|
|
|
|
for f in ./color/svg/*.svg; do
|
|
|
|
basename=$(basename "$f" .svg)
|
|
|
|
hexcodes+=(''${basename//-/ })
|
|
|
|
filename=$(basename "$f");
|
|
|
|
cp "./color/svg/$filename" "./font/tmp-color/$filename"
|
|
|
|
cp "./black/svg/$filename" "./font/tmp-black/$filename"
|
|
|
|
done
|
|
|
|
|
2019-10-02 11:33:31 +00:00
|
|
|
hexcodes=($(uniq<<<"''${hexcodes[@]}"))
|
2019-10-01 13:43:42 +00:00
|
|
|
|
2019-10-02 11:33:31 +00:00
|
|
|
for h in ''${hexcodes[@]}; do
|
2019-10-01 13:43:42 +00:00
|
|
|
filename="$h.svg"
|
|
|
|
if [ ! -e "./color/svg/$filename" ]; then
|
|
|
|
echo "$h is missing -> substitute with \"Missing Glyph\": $filename"
|
|
|
|
cp $missingGlyphColor "./font/tmp-color/$filename"
|
|
|
|
cp $missingGlyphBlack "./font/tmp-black/$filename"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Actually build the font:
|
|
|
|
cd font
|
2020-07-06 10:21:48 +00:00
|
|
|
scfbuild ${scfbuildOptions} -c scfbuild-${variant}.yml
|
2019-10-01 13:43:42 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm644 ${filename} $out/share/fonts/truetype/${filename}
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
license = licenses.cc-by-sa-40;
|
|
|
|
maintainers = with maintainers; [ fgaz ];
|
|
|
|
platforms = platforms.all;
|
|
|
|
homepage = "https://openmoji.org/";
|
|
|
|
downloadPage = "https://github.com/hfg-gmuend/openmoji/releases";
|
|
|
|
description = "Open-source emojis for designers, developers and everyone else";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|