fix ttf fonts

This commit is contained in:
Rongsong Shen 2026-01-22 14:42:49 +08:00
parent 828497661d
commit d6e6711f40
2 changed files with 63 additions and 0 deletions

View file

@ -74,6 +74,7 @@ let
struct2json = callPackage ./pkgs/s/struct2json/package.nix { struct2json = callPackage ./pkgs/s/struct2json/package.nix {
pkgs = pkgs; pkgs = pkgs;
}; };
my-ttf-fonts = callPackage ./pkgs/f/fonts/package.nix {};
in in
{ {
xbuild = xbuild; xbuild = xbuild;
@ -87,4 +88,5 @@ in
libcello_debug = libcello_debug; libcello_debug = libcello_debug;
packcc = packcc_main; packcc = packcc_main;
struct2json = struct2json; struct2json = struct2json;
my-ttf-fonts = my-ttf-fonts;
} }

61
pkgs/f/fonts/package.nix Normal file
View file

@ -0,0 +1,61 @@
{
lib,
stdenv,
# fetchFromGitea,
# fetchFromGitHub,
# fetchgit,
pkgs? import <nixpkgs> {},
pkg-config,
}:
let
meta = with lib; {
description = "Some true type fonts";
homepage = "https://github.com/shen390s/my-ttf-fonts";
license = lib.licenses.asl20;
platforms = lib.platforms.unix;
};
pname = "my-ttf-fonts";
version = "1.0";
mysource = pkgs.runCommand "download-fonts" {
nativeBuiltInputs = [ pkgs.curl ];
outputHash = "sha256-JMWxG0lCkzXhuBoBtEk8N0g6qrLRJo0WGki9A+yTbhU=";
outputHashAlgo = "sha256";
outputHashMode = "flat";
} ''
${pkgs.curl}/bin/curl --output $out \
--location \
--max-redirs 20 \
--retry 3 \
--disable-epsv \
--cookie-jar cookies \
--insecure \
--user-agent curl/8.17.0 -C - --fail \
https://gitee.com/shen390s/my-ttf-fonts/archive/refs/tags/v1.0.tar.gz
'';
in
stdenv.mkDerivation (finalAttrs: {
pname = pname;
version = version;
src = mysource;
unpackPhase = ''
tar -zxvf $src
'';
installPhase = ''
mkdir -p $out/share/fonts/truetype
_fontdir="${pname}-v${version}"
if [ -d $_fontdir/fonts/truetype ]; then
ls $_fontdir/fonts/truetype/*
cp -r $_fontdir/fonts/truetype/*.ttf $out/share/fonts/truetype/
cp -r $_fontdir/fonts/truetype/*.ttc $out/share/fonts/truetype/
else
echo "No fonts found in $_fontdir/fonts/truetype"
exit 0
fi
'';
inherit meta;
})