mirror of
https://github.com/daylinmorgan/monolisa-nerdfont-patch.git
synced 2024-11-13 18:07:52 -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
|
!**/.gitkeep
|
||||||
|
|
||||||
nerd-fonts
|
nerd-fonts
|
||||||
.env
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -1,13 +1,12 @@
|
||||||
-include .env
|
|
||||||
ARGS ?= -c
|
ARGS ?= -c
|
||||||
|
|
||||||
NF_SRC := $(shell ./bin/get-font-files src)
|
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 | apply nerd fonts patch
|
||||||
patch: ./bin/font-patcher
|
patch: ./bin/font-patcher
|
||||||
@./bin/patch-monolisa \
|
@./bin/patch-monolisa \
|
||||||
$(FONT_FLAGS) \
|
$(foreach f,$(FONT_SRC),-f '$(f)') \
|
||||||
$(ARGS)
|
$(ARGS)
|
||||||
|
|
||||||
## update-fonts | move fonts and update fc-cache
|
## 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
|
exts = sys.argv[2].split(",") if len(sys.argv) == 3 else None
|
||||||
|
|
||||||
for f in find_files(search_path, exts):
|
for f in find_files(search_path, exts):
|
||||||
sys.stdout.write(f"-f '{f}' ")
|
print(f)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
|
@ -15,7 +16,6 @@ from typing import List, Set
|
||||||
|
|
||||||
class Color:
|
class Color:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.bold = "\033[1m"
|
|
||||||
self.red = "\033[1;31m"
|
self.red = "\033[1;31m"
|
||||||
self.green = "\033[1;32m"
|
self.green = "\033[1;32m"
|
||||||
self.yellow = "\033[1;33m"
|
self.yellow = "\033[1;33m"
|
||||||
|
@ -80,7 +80,7 @@ class Spinner:
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(
|
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:
|
) -> None:
|
||||||
"""run a subcommand
|
"""run a subcommand
|
||||||
Args:
|
Args:
|
||||||
|
@ -90,7 +90,7 @@ def run_cmd(
|
||||||
"""
|
"""
|
||||||
|
|
||||||
p = subprocess.run(
|
p = subprocess.run(
|
||||||
command,
|
shlex.split(command),
|
||||||
stdout=None if verbose else subprocess.PIPE,
|
stdout=None if verbose else subprocess.PIPE,
|
||||||
stderr=None if verbose else subprocess.STDOUT,
|
stderr=None if verbose else subprocess.STDOUT,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
|
@ -136,27 +136,19 @@ def patch_single_font(
|
||||||
output_path = output_dir / font_path.parent.name.replace("MonoLisa/", "")
|
output_path = output_dir / font_path.parent.name.replace("MonoLisa/", "")
|
||||||
output_path.mkdir(exist_ok=True)
|
output_path.mkdir(exist_ok=True)
|
||||||
|
|
||||||
cmd = [
|
cmd = (
|
||||||
"fontforge",
|
"fontforge -script "
|
||||||
"-script",
|
f"./bin/font-patcher {font_path} "
|
||||||
"./bin/font-patcher",
|
"--glyphdir ./src/glyphs/ "
|
||||||
"--glyphdir",
|
f"-o {output_path} "
|
||||||
"./src/glyphs/",
|
f"{fp_args}"
|
||||||
"-out",
|
)
|
||||||
f"{output_path}",
|
|
||||||
*fp_args.split(" "),
|
|
||||||
f"{font_path}",
|
|
||||||
]
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
echo(f"cmd: {' '.join(cmd)}")
|
echo(f"cmd: {cmd}")
|
||||||
run_cmd(cmd, font_path, verbose)
|
run_cmd(cmd, font_path, verbose)
|
||||||
else:
|
else:
|
||||||
with Spinner(
|
with Spinner(f"{color.yellow}:::{color.end} Patching {display_name}... "):
|
||||||
f"{color.yellow}:::{color.end} Patching font "
|
|
||||||
f"{color.bold}{font_path.name}{color.end}... "
|
|
||||||
):
|
|
||||||
|
|
||||||
run_cmd(cmd, font_path, verbose)
|
run_cmd(cmd, font_path, verbose)
|
||||||
|
|
||||||
echo(f"{display_name} patched!", hue="green")
|
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 = (output_dir / font_dir_path.name).resolve()
|
||||||
output_path.mkdir(exist_ok=True)
|
output_path.mkdir(exist_ok=True)
|
||||||
|
|
||||||
cmd = [
|
cmd = (
|
||||||
"docker",
|
"docker run --rm "
|
||||||
"run",
|
f"-v '{font_dir_path}:/in' "
|
||||||
"--rm",
|
f"-v '{output_path}:/out' "
|
||||||
"-v",
|
f" -u '{os.getuid()}:{os.getegid()}' "
|
||||||
f"{font_dir_path}:/in",
|
"nerdfonts/patcher "
|
||||||
"-v",
|
f"{fp_args}"
|
||||||
f"{output_path}:/out",
|
)
|
||||||
"-u",
|
|
||||||
f"{os.getuid()}:{os.getegid()}",
|
|
||||||
"nerdfonts/patcher",
|
|
||||||
*fp_args.split(" "),
|
|
||||||
]
|
|
||||||
|
|
||||||
# ignoring the fact that docker exits with code 1
|
# ignoring the fact that docker exits with code 1
|
||||||
if verbose:
|
if verbose:
|
||||||
echo(f"cmd: {' '.join(cmd)}")
|
echo(f"cmd: {cmd}")
|
||||||
run_cmd(cmd, font_dir_path, verbose, ignore_error=True)
|
run_cmd(cmd, font_dir_path, verbose, ignore_error=True)
|
||||||
else:
|
else:
|
||||||
with Spinner(
|
with Spinner(
|
||||||
f"{color.yellow}:::{color.end} Patching fonts in "
|
f"{color.yellow}:::{color.end} Patching fonts in {font_dir_path.name}... "
|
||||||
f"{color.bold}{font_dir_path.name}{color.end}... "
|
|
||||||
):
|
):
|
||||||
run_cmd(cmd, font_dir_path, verbose, ignore_error=True)
|
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)
|
patch_font_dir_docker(font_dir, args.output, fp_args, args.verbose)
|
||||||
else:
|
else:
|
||||||
for fontfile in args.font_path:
|
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("fonts are patched", hue="green")
|
||||||
echo("Happy typing!", hue="green")
|
echo("Happy typing!", hue="green")
|
||||||
|
|
Loading…
Reference in a new issue