mirror of
https://github.com/daylinmorgan/monolisa-nerdfont-patch.git
synced 2024-12-22 23:10:44 -06:00
Compare commits
No commits in common. "e5caea257c4da8a355509a9160b4585e55b86587" and "8bf47bf87782c9f906bffe6d0aab512af0673353" have entirely different histories.
e5caea257c
...
8bf47bf877
4 changed files with 27 additions and 42 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,4 +6,3 @@ patched/*
|
|||
!**/.gitkeep
|
||||
|
||||
nerd-fonts
|
||||
.env
|
||||
|
|
5
Makefile
5
Makefile
|
@ -1,13 +1,12 @@
|
|||
-include .env
|
||||
ARGS ?= -c
|
||||
|
||||
NF_SRC := $(shell ./bin/get-font-files src)
|
||||
FONT_FLAGS := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2')
|
||||
FONT_SRC := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2')
|
||||
|
||||
## patch | apply nerd fonts patch
|
||||
patch: ./bin/font-patcher
|
||||
@./bin/patch-monolisa \
|
||||
$(FONT_FLAGS) \
|
||||
$(foreach f,$(FONT_SRC),-f '$(f)') \
|
||||
$(ARGS)
|
||||
|
||||
## update-fonts | move fonts and update fc-cache
|
||||
|
|
|
@ -21,7 +21,7 @@ def main():
|
|||
exts = sys.argv[2].split(",") if len(sys.argv) == 3 else None
|
||||
|
||||
for f in find_files(search_path, exts):
|
||||
sys.stdout.write(f"-f '{f}' ")
|
||||
print(f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import argparse
|
||||
import itertools
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
|
@ -15,7 +16,6 @@ from typing import List, Set
|
|||
|
||||
class Color:
|
||||
def __init__(self):
|
||||
self.bold = "\033[1m"
|
||||
self.red = "\033[1;31m"
|
||||
self.green = "\033[1;32m"
|
||||
self.yellow = "\033[1;33m"
|
||||
|
@ -80,7 +80,7 @@ class Spinner:
|
|||
|
||||
|
||||
def run_cmd(
|
||||
command: List[str], fontfile: Path, verbose: bool, ignore_error: bool = False
|
||||
command: str, fontfile: Path, verbose: bool, ignore_error: bool = False
|
||||
) -> None:
|
||||
"""run a subcommand
|
||||
Args:
|
||||
|
@ -90,7 +90,7 @@ def run_cmd(
|
|||
"""
|
||||
|
||||
p = subprocess.run(
|
||||
command,
|
||||
shlex.split(command),
|
||||
stdout=None if verbose else subprocess.PIPE,
|
||||
stderr=None if verbose else subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
|
@ -136,27 +136,19 @@ def patch_single_font(
|
|||
output_path = output_dir / font_path.parent.name.replace("MonoLisa/", "")
|
||||
output_path.mkdir(exist_ok=True)
|
||||
|
||||
cmd = [
|
||||
"fontforge",
|
||||
"-script",
|
||||
"./bin/font-patcher",
|
||||
"--glyphdir",
|
||||
"./src/glyphs/",
|
||||
"-out",
|
||||
f"{output_path}",
|
||||
*fp_args.split(" "),
|
||||
f"{font_path}",
|
||||
]
|
||||
cmd = (
|
||||
"fontforge -script "
|
||||
f"./bin/font-patcher {font_path} "
|
||||
"--glyphdir ./src/glyphs/ "
|
||||
f"-o {output_path} "
|
||||
f"{fp_args}"
|
||||
)
|
||||
|
||||
if verbose:
|
||||
echo(f"cmd: {' '.join(cmd)}")
|
||||
echo(f"cmd: {cmd}")
|
||||
run_cmd(cmd, font_path, verbose)
|
||||
else:
|
||||
with Spinner(
|
||||
f"{color.yellow}:::{color.end} Patching font "
|
||||
f"{color.bold}{font_path.name}{color.end}... "
|
||||
):
|
||||
|
||||
with Spinner(f"{color.yellow}:::{color.end} Patching {display_name}... "):
|
||||
run_cmd(cmd, font_path, verbose)
|
||||
|
||||
echo(f"{display_name} patched!", hue="green")
|
||||
|
@ -173,28 +165,22 @@ def patch_font_dir_docker(
|
|||
output_path = (output_dir / font_dir_path.name).resolve()
|
||||
output_path.mkdir(exist_ok=True)
|
||||
|
||||
cmd = [
|
||||
"docker",
|
||||
"run",
|
||||
"--rm",
|
||||
"-v",
|
||||
f"{font_dir_path}:/in",
|
||||
"-v",
|
||||
f"{output_path}:/out",
|
||||
"-u",
|
||||
f"{os.getuid()}:{os.getegid()}",
|
||||
"nerdfonts/patcher",
|
||||
*fp_args.split(" "),
|
||||
]
|
||||
cmd = (
|
||||
"docker run --rm "
|
||||
f"-v '{font_dir_path}:/in' "
|
||||
f"-v '{output_path}:/out' "
|
||||
f" -u '{os.getuid()}:{os.getegid()}' "
|
||||
"nerdfonts/patcher "
|
||||
f"{fp_args}"
|
||||
)
|
||||
|
||||
# ignoring the fact that docker exits with code 1
|
||||
if verbose:
|
||||
echo(f"cmd: {' '.join(cmd)}")
|
||||
echo(f"cmd: {cmd}")
|
||||
run_cmd(cmd, font_dir_path, verbose, ignore_error=True)
|
||||
else:
|
||||
with Spinner(
|
||||
f"{color.yellow}:::{color.end} Patching fonts in "
|
||||
f"{color.bold}{font_dir_path.name}{color.end}... "
|
||||
f"{color.yellow}:::{color.end} Patching fonts in {font_dir_path.name}... "
|
||||
):
|
||||
run_cmd(cmd, font_dir_path, verbose, ignore_error=True)
|
||||
|
||||
|
@ -222,7 +208,8 @@ def main():
|
|||
patch_font_dir_docker(font_dir, args.output, fp_args, args.verbose)
|
||||
else:
|
||||
for fontfile in args.font_path:
|
||||
patch_single_font(Path(fontfile), args.output, fp_args, args.verbose)
|
||||
patch_single_font(Path(fontfile), args.output,
|
||||
fp_args, args.verbose)
|
||||
|
||||
echo("fonts are patched", hue="green")
|
||||
echo("Happy typing!", hue="green")
|
||||
|
|
Loading…
Reference in a new issue