mirror of
https://github.com/daylinmorgan/monolisa-nerdfont-patch.git
synced 2024-11-09 16:43:14 -06:00
Compare commits
2 commits
8bf47bf877
...
e5caea257c
Author | SHA1 | Date | |
---|---|---|---|
e5caea257c | |||
d3b2d37f18 |
4 changed files with 42 additions and 27 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ patched/*
|
||||||
!**/.gitkeep
|
!**/.gitkeep
|
||||||
|
|
||||||
nerd-fonts
|
nerd-fonts
|
||||||
|
.env
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -1,12 +1,13 @@
|
||||||
|
-include .env
|
||||||
ARGS ?= -c
|
ARGS ?= -c
|
||||||
|
|
||||||
NF_SRC := $(shell ./bin/get-font-files src)
|
NF_SRC := $(shell ./bin/get-font-files src)
|
||||||
FONT_SRC := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2')
|
FONT_FLAGS := $(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 \
|
||||||
$(foreach f,$(FONT_SRC),-f '$(f)') \
|
$(FONT_FLAGS) \
|
||||||
$(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):
|
||||||
print(f)
|
sys.stdout.write(f"-f '{f}' ")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
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
|
||||||
|
@ -16,6 +15,7 @@ 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: str, fontfile: Path, verbose: bool, ignore_error: bool = False
|
command: List[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(
|
||||||
shlex.split(command),
|
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,19 +136,27 @@ 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 -script "
|
"fontforge",
|
||||||
f"./bin/font-patcher {font_path} "
|
"-script",
|
||||||
"--glyphdir ./src/glyphs/ "
|
"./bin/font-patcher",
|
||||||
f"-o {output_path} "
|
"--glyphdir",
|
||||||
f"{fp_args}"
|
"./src/glyphs/",
|
||||||
)
|
"-out",
|
||||||
|
f"{output_path}",
|
||||||
|
*fp_args.split(" "),
|
||||||
|
f"{font_path}",
|
||||||
|
]
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
echo(f"cmd: {cmd}")
|
echo(f"cmd: {' '.join(cmd)}")
|
||||||
run_cmd(cmd, font_path, verbose)
|
run_cmd(cmd, font_path, verbose)
|
||||||
else:
|
else:
|
||||||
with Spinner(f"{color.yellow}:::{color.end} Patching {display_name}... "):
|
with Spinner(
|
||||||
|
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")
|
||||||
|
@ -165,22 +173,28 @@ 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 run --rm "
|
"docker",
|
||||||
f"-v '{font_dir_path}:/in' "
|
"run",
|
||||||
f"-v '{output_path}:/out' "
|
"--rm",
|
||||||
f" -u '{os.getuid()}:{os.getegid()}' "
|
"-v",
|
||||||
"nerdfonts/patcher "
|
f"{font_dir_path}:/in",
|
||||||
f"{fp_args}"
|
"-v",
|
||||||
)
|
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: {cmd}")
|
echo(f"cmd: {' '.join(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 {font_dir_path.name}... "
|
f"{color.yellow}:::{color.end} Patching fonts in "
|
||||||
|
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)
|
||||||
|
|
||||||
|
@ -208,8 +222,7 @@ 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,
|
patch_single_font(Path(fontfile), args.output, fp_args, args.verbose)
|
||||||
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