openmoji-color,openmoji-black: 14.0.0 -> 15.0.0

This commit is contained in:
Sophie Tauchert 2023-12-21 19:14:52 +01:00 committed by Francesco Gazzetta
parent dbdb1f1b8b
commit 3da286dbe2
3 changed files with 130 additions and 61 deletions

View File

@ -0,0 +1,77 @@
diff --git a/helpers/generate-fonts-runner.sh b/helpers/generate-fonts-runner.sh
index 21267e50f..873b5c664 100755
--- a/helpers/generate-fonts-runner.sh
+++ b/helpers/generate-fonts-runner.sh
@@ -25,10 +25,10 @@ mkdir -p "$build_dir"
# Change these to enable/disable formats
# Remember to update font/README.md accordingly
-methods_black=(glyf)
-methods_color=(cbdt glyf_colr_0 glyf_colr_1 sbix picosvgz untouchedsvgz)
+#methods_black=(glyf)
+#methods_color=(cbdt glyf_colr_0 glyf_colr_1 sbix picosvgz untouchedsvgz)
-saturations=(black color)
+#saturations=(black color)
for saturation in "${saturations[@]}"; do
case "$saturation" in
black)
@@ -43,6 +43,7 @@ for saturation in "${saturations[@]}"; do
mkdir -p "$build_dir/$saturation"
for method in "${methods[@]}"; do
+ if [ -z "$method" ]; then continue; fi
cat >"$build_dir/$saturation/OpenMoji-$saturation-$method.toml" <<-EOF
output_file = "$build_dir/$saturation/OpenMoji-$saturation-$method.ttf"
color_format = "$method"
@@ -55,10 +56,7 @@ default = 400
[master.regular]
style_name = "Regular"
-
-# To quickly check build reverse comments below
-srcs = ["/mnt/$saturation/svg/*.svg"]
-# srcs = ["/mnt/$saturation/svg/1F923.svg", "/mnt/$saturation/svg/1F1E9-1F1F0.svg"]
+srcs = ["$(pwd)/$saturation/svg/*.svg"]
[master.regular.position]
wght = 400
@@ -71,7 +69,7 @@ EOF
for method in "${methods[@]}"; do
# Generate XML for font
sed "s/Color/${saturation^}/;" \
- /mnt/data/OpenMoji-Color.ttx \
+ data/OpenMoji-Color.ttx \
> "$build_dir/$saturation/OpenMoji-$saturation-$method.ttx"
# Add version to XML
@@ -89,25 +87,21 @@ EOF
# Compress with WOFF2
woff2_compress "$build_dir/fonts/OpenMoji-$saturation-$method/OpenMoji-$saturation-$method.ttf"
-
- # Generate font demo
- /mnt/helpers/generate-font-demo.js "OpenMoji-$saturation-$method.woff2" "$build_dir/fonts/OpenMoji-$saturation-$method"
done
done
-for colr_version in 0 1; do
+for colr_version in "${maximumColorVersions[@]}"; do
+ if [ -z "$colr_version" ]; then continue; fi
# Make TTF with both COLR and SVG font data in it
mkdir -p "$build_dir/fonts/OpenMoji-color-colr${colr_version}_svg"
- maximum_color \
+ maximum_color --build_dir="$build_dir/color" \
"$build_dir/fonts/OpenMoji-color-glyf_colr_${colr_version}/OpenMoji-color-glyf_colr_${colr_version}.ttf"\
--output_file "$build_dir/fonts/OpenMoji-color-colr${colr_version}_svg/OpenMoji-color-colr${colr_version}_svg.ttf"
woff2_compress "$build_dir/fonts/OpenMoji-color-colr${colr_version}_svg/OpenMoji-color-colr${colr_version}_svg.ttf"
- /mnt/helpers/generate-font-demo.js\
- "OpenMoji-color-colr${colr_version}_svg.woff2"\
- "$build_dir/fonts/OpenMoji-color-colr${colr_version}_svg"
+ rm -rf "$build_dir/fonts/OpenMoji-color-glyf_colr_${colr_version}"
done
echo "Done building fonts!"

View File

@ -1,93 +1,85 @@
{ lib
, stdenv
, stdenvNoCC
, fetchFromGitHub
, fetchpatch
, scfbuild
, fontforge
, node-glob
, libuninameslist
, nodejs
, nodePackages
, nanoemoji
, python3Packages
, variant ? "color" # "color" or "black"
, woff2
, xmlstarlet
# available color formats: ["cbdt" "glyf_colr_0" "glyf_colr_1" "sbix" "picosvgz" "untouchedsvgz"]
# available black formats: ["glyf"]
, fontFormats ? [ "glyf" "cbdt" "glyf_colr_0" "glyf_colr_1" ]
# when at least one of the glyf_colr_0/1 formats is specified, whether to build maximum color fonts
# "none" to not build any, "svg" to build colr+svg, "bitmap" to build cbdt+colr+svg fonts
, buildMaximumColorFonts ? "bitmap"
}:
let
filename = builtins.replaceStrings
[ "color" "black" ]
[ "OpenMoji-Color.ttf" "OpenMoji-Black.ttf" ]
variant;
# all available methods
methods = {
black = [ "glyf" ];
color = [ "cbdt" "glyf_colr_0" "glyf_colr_1" "sbix" "picosvgz" "untouchedsvgz" ];
};
in
# With newer fontforge the build hangs, see
# https://github.com/NixOS/nixpkgs/issues/167869
# Patches etc taken from
# https://github.com/NixOS/nixpkgs/commit/69da642a5a9bb433138ba1b13c8d56fb5bb6ec05
fontforge-20201107 = fontforge.overrideAttrs (old: rec {
version = "20201107";
src = fetchFromGitHub {
owner = "fontforge";
repo = "fontforge";
rev = version;
sha256 = "sha256-Rl/5lbXaPgIndANaD0IakaDus6T53FjiBb45FIuGrvc=";
};
patches = [
(fetchpatch {
url = "https://salsa.debian.org/fonts-team/fontforge/raw/76bffe6ccf8ab20a0c81476a80a87ad245e2fd1c/debian/patches/0001-add-extra-cmake-install-rules.patch";
sha256 = "u3D9od2xLECNEHhZ+8dkuv9818tPkdP6y/Tvd9CADJg=";
})
(fetchpatch {
url = "https://github.com/fontforge/fontforge/commit/69e263b2aff29ad22f97f13935cfa97a1eabf207.patch";
sha256 = "06yyf90605aq6ppfiz83mqkdmnaq5418axp9jgsjyjq78b00xb29";
})
];
buildInputs = old.buildInputs ++ [ libuninameslist ];
});
scfbuild-with-fontforge-20201107 = scfbuild.override (old: {
fontforge = fontforge-20201107;
});
assert lib.asserts.assertEachOneOf "fontFormats" fontFormats (methods.black ++ methods.color);
assert lib.asserts.assertOneOf "buildMaximumColorFonts" buildMaximumColorFonts [ "none" "bitmap" "svg" ];
in stdenv.mkDerivation rec {
stdenvNoCC.mkDerivation rec {
pname = "openmoji";
version = "14.0.0";
version = "15.0.0";
src = fetchFromGitHub {
owner = "hfg-gmuend";
repo = pname;
rev = version;
sha256 = "sha256-XnSRSlWXOMeSaO6dKaOloRg3+sWS4BSaro4bPqOyKmE=";
hash = "sha256-659ONkHU45Z2789ay0yLero9j5nFWhslpJad++4oNN8=";
};
nativeBuildInputs = [
scfbuild-with-fontforge-20201107
nodejs
node-glob
nodePackages.lodash
patches = [
# fix paths and variables for nix build and skip generating font demos
./build.patch
];
postPatch = ''
# this is API change in glob >9
substituteInPlace helpers/generate-font-glyphs.js \
--replace "require('glob').sync" "require('glob').globSync"
nativeBuildInputs = [
nanoemoji
python3Packages.fonttools
woff2
xmlstarlet
];
methods_black = builtins.filter (m: builtins.elem m fontFormats) methods.black;
methods_color = builtins.filter (m: builtins.elem m fontFormats) methods.color;
saturations = lib.optional (methods_black != [ ]) "black" ++ lib.optional (methods_color != [ ]) "color";
maximumColorVersions = lib.optionals (buildMaximumColorFonts != "none") (
lib.optional (builtins.elem "glyf_colr_0" fontFormats) "0"
++ lib.optional (builtins.elem "glyf_colr_1" fontFormats) "1"
);
postPatch = lib.optionalString (buildMaximumColorFonts == "bitmap") ''
substituteInPlace helpers/generate-fonts-runner.sh \
--replace 'maximum_color' 'maximum_color --bitmaps'
'';
buildPhase = ''
runHook preBuild
node helpers/generate-font-glyphs.js
cd font
scfbuild -c scfbuild-${variant}.yml
bash helpers/generate-fonts-runner.sh "$(pwd)/build" "${version}"
runHook postBuild
'';
installPhase = ''
install -Dm644 ${filename} $out/share/fonts/truetype/${filename}
runHook preInstall
mkdir -p $out/share/fonts/truetype $out/share/fonts/woff2
cp build/fonts/*/*.ttf $out/share/fonts/truetype/
cp build/fonts/*/*.woff2 $out/share/fonts/woff2/
runHook postInstall
'';
meta = with lib; {
license = licenses.cc-by-sa-40;
maintainers = with maintainers; [ fgaz ];
maintainers = with maintainers; [ _999eagle fgaz ];
platforms = platforms.all;
homepage = "https://openmoji.org/";
downloadPage = "https://github.com/hfg-gmuend/openmoji/releases";

View File

@ -29395,9 +29395,9 @@ with pkgs;
open-sans = callPackage ../data/fonts/open-sans { };
openmoji-color = callPackage ../data/fonts/openmoji { variant = "color"; };
openmoji-color = callPackage ../data/fonts/openmoji { fontFormats = ["glyf_colr_0"]; };
openmoji-black = callPackage ../data/fonts/openmoji { variant = "black"; };
openmoji-black = callPackage ../data/fonts/openmoji { fontFormats = ["glyf"]; };
openzone-cursors = callPackage ../data/themes/openzone { };