Compare commits

...

4 Commits

Author SHA1 Message Date
Daylin Morgan 67e41cd362
build: add package for nix run 2024-01-30 20:40:47 -06:00
Daylin Morgan 569b5a3569
chore: use only ruff 2024-01-30 20:34:03 -06:00
Daylin Morgan 4a52ad225b
feat: add flake.nix 2024-01-30 20:34:03 -06:00
Daylin Morgan b23fb6732e
feat: add file paths to debug-info 2024-01-30 20:34:03 -06:00
8 changed files with 115 additions and 20 deletions

1
.gitignore vendored
View File

@ -185,3 +185,4 @@ patched/*
nerd-fonts nerd-fonts
.env .env
font-patcher-log.txt font-patcher-log.txt
result

View File

@ -1,20 +1,14 @@
exclude: "^(src/.*|bin/scripts|font-patcher)" exclude: "^(src/.*|bin/scripts|font-patcher)"
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 rev: v4.5.0
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/psf/black - repo: https://github.com/astral-sh/ruff-pre-commit
rev: 23.1.0 rev: v0.1.14
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.257'
hooks: hooks:
- id: ruff-format
- id: ruff - id: ruff
- repo: https://github.com/shellcheck-py/shellcheck-py args: [ --fix ]
rev: v0.9.0.2
hooks:
- id: shellcheck

View File

@ -83,6 +83,14 @@ make update-fonts
You can verify the fonts have been added with `make check`. You can verify the fonts have been added with `make check`.
## with Nix
You can run using the included `flake.nix`.
```bash
nix run "github:daylinmorgan/monolisa-nerdfont-patch"
```
## Contributing ## Contributing
Before making changes to to any of the scripts in `bin` you should first install `pre-commit`. Before making changes to to any of the scripts in `bin` you should first install `pre-commit`.

View File

@ -8,11 +8,18 @@ divider() {
} }
show-version() { show-version() {
printf "%s %s %s\n" "$(divider)" "$1" "$(divider)" printf "%s %s %s\n" "$(divider)" "$1" "$(divider)"
which "$1" which "$1" 2>/dev/null
"$@" "$@"
} }
show-dir() {
dir="$( dirname -- "$( readlink -f -- "$0"; )"; )"/../"$1"
printf "%s\n%s\n%s\n" "$(divider)" "$(tree "$dir")" "$(divider)"
}
show-version python --version show-version python --version
show-version fontforge --version show-version fontforge --version
show-version docker --version show-version docker --version
show-version uname -a show-version uname -a
show-dir MonoLisa
show-dir patched

27
flake.lock Normal file
View File

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1706371002,
"narHash": "sha256-dwuorKimqSYgyu8Cw6ncKhyQjUDOyuXoxDTVmAXq88s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c002c6aa977ad22c60398daaa9be52f2203d0006",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

58
flake.nix Normal file
View File

@ -0,0 +1,58 @@
{
description = "brain";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = inputs @ {
self,
nixpkgs,
}: let
inherit (nixpkgs.lib) genAttrs;
forAllSystems = f:
genAttrs
["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"]
(system: f nixpkgs.legacyPackages.${system});
in {
packages = forAllSystems (
pkgs:
with pkgs; {
default = stdenv.mkDerivation {
name = "monolisa-nerdfont-patch";
src = ./.;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
fontforge
python3
];
unpackPhase = ":";
buildPhase = ":";
installPhase = ''
mkdir -p $out/bin
install -m755 -D ${./patch-monolisa} $out/bin/monolisa-nerdfont-patch
install -m755 -D ${./font-patcher} $out/bin/font-patcher
cp -r ${./bin} $out/bin/bin
cp -r ${./src} $out/bin/src
'';
postFixup = ''
wrapProgram $out/bin/monolisa-nerdfont-patch \
--set PATH ${lib.makeBinPath [
fontforge
]}
'';
};
}
);
devShells = forAllSystems (
pkgs:
with pkgs; {
default = mkShell {
buildInputs = [
fontforge
python3
pre-commit
];
};
}
);
};
}

View File

@ -10,8 +10,6 @@ import time
from pathlib import Path from pathlib import Path
from typing import List, Set from typing import List, Set
FONT_SRC = (Path(__file__).parent / "MonoLisa").absolute()
class Color: class Color:
def __init__(self): def __init__(self):
@ -133,16 +131,16 @@ def patch_single_font(
font_path: Path, output_dir: Path, fp_args: str, verbose: bool font_path: Path, output_dir: Path, fp_args: str, verbose: bool
) -> None: ) -> None:
# update display name to full resolved path # update display name to full resolved path
rel_path = font_path.absolute().relative_to(FONT_SRC) rel_path = font_path.absolute()
output_path = (output_dir / rel_path).parent output_path = (output_dir / rel_path.parent.name).absolute()
output_path.mkdir(exist_ok=True, parents=True) output_path.mkdir(exist_ok=True, parents=True)
cmd = [ cmd = [
"fontforge", "fontforge",
"-script", "-script",
"./font-patcher", f"{Path(__file__).parent}/font-patcher",
"--glyphdir", "--glyphdir",
"./src/glyphs/", f"{Path(__file__).parent}/src/glyphs/",
"-out", "-out",
f"{output_path}", f"{output_path}",
f"{font_path.absolute()}", f"{font_path.absolute()}",
@ -171,7 +169,9 @@ def collect_files_by_dir(fontfiles: List[Path]) -> Set[Path]:
def patch_font_dir_docker( def patch_font_dir_docker(
font_dir_path: Path, output_dir: Path, fp_args: str, verbose: bool font_dir_path: Path, output_dir: Path, fp_args: str, verbose: bool
) -> None: ) -> None:
output_path = (output_dir / font_dir_path.relative_to(FONT_SRC)).absolute() output_path = (
output_dir / font_dir_path.relative_to(font_dir_path.parent)
).absolute()
output_path.mkdir(exist_ok=True, parents=True) output_path.mkdir(exist_ok=True, parents=True)
cmd = [ cmd = [