mirror of
https://github.com/daylinmorgan/monolisa-nerdfont-patch.git
synced 2024-12-23 07:20:44 -06:00
Compare commits
No commits in common. "326445e89c4656e1548ae099e97b2d614094bb0a" and "e5caea257c4da8a355509a9160b4585e55b86587" have entirely different histories.
326445e89c
...
e5caea257c
5 changed files with 20 additions and 51 deletions
2
Makefile
2
Makefile
|
@ -37,7 +37,7 @@ lint:
|
||||||
## clean | remove patched fonts
|
## clean | remove patched fonts
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
@rm -rf patched/*
|
@rm -r patched/*
|
||||||
|
|
||||||
msg = $(call tprint,{a.bold}==>{a.end} {a.b_magenta}$(1){a.end} {a.bold}<=={a.end})
|
msg = $(call tprint,{a.bold}==>{a.end} {a.b_magenta}$(1){a.end} {a.bold}<=={a.end})
|
||||||
USAGE = {a.b_green}Update MonoLisa with Nerd Fonts! {a.end}\n\n{a.header}usage{a.end}:\n make <recipe>\n
|
USAGE = {a.b_green}Update MonoLisa with Nerd Fonts! {a.end}\n\n{a.header}usage{a.end}:\n make <recipe>\n
|
||||||
|
|
14
README.md
14
README.md
|
@ -2,24 +2,20 @@
|
||||||
|
|
||||||
_Most_ Batteries included repo to patch MonoLisa with Nerd Fonts glyphs
|
_Most_ Batteries included repo to patch MonoLisa with Nerd Fonts glyphs
|
||||||
|
|
||||||
tested w/ MonoLisa v2.003
|
tested w/ MonoLisa v1.808
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./assets/help.svg" width=400>
|
<img src="./assets/help.svg" width=400>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Dependencies
|
## Before You Begin
|
||||||
|
|
||||||
- `python`
|
First you will need to install `fontforge`
|
||||||
- `make`
|
There are a number of caveats to invoking the `font-patcher` script.
|
||||||
- `fontforge` OR `docker`
|
|
||||||
|
|
||||||
|
|
||||||
There are some caveats to invoking the `font-patcher` script.
|
|
||||||
Some of which are explained by [nerd fonts](https://github.com/ryanoasis/nerd-fonts#font-patcher).
|
Some of which are explained by [nerd fonts](https://github.com/ryanoasis/nerd-fonts#font-patcher).
|
||||||
To use `font-patcher` with `fontforge` first ensure it is installed (or see below for `docker` approach).
|
|
||||||
|
|
||||||
On Arch:
|
On Arch:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo pacman -S fontforge
|
sudo pacman -S fontforge
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
EXTS = ["otf", "ttf", "woff", "woff2"]
|
|
||||||
|
|
||||||
|
|
||||||
def find_files(search_path, exts=None):
|
def find_files(search_path, exts=None):
|
||||||
return (
|
return (
|
||||||
|
@ -20,7 +18,7 @@ def main():
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
search_path = Path(sys.argv[1])
|
search_path = Path(sys.argv[1])
|
||||||
exts = sys.argv[2].split(",") if len(sys.argv) == 3 else EXTS
|
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}' ")
|
sys.stdout.write(f"-f '{f}' ")
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
divider() {
|
|
||||||
N=10
|
|
||||||
for ((i = 0; i < N; ++i)); do
|
|
||||||
printf '-'
|
|
||||||
done
|
|
||||||
}
|
|
||||||
show-version() {
|
|
||||||
printf "%s %s %s\n" "$(divider)" "$1" "$(divider)"
|
|
||||||
which "$1"
|
|
||||||
"$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
show-version python --version
|
|
||||||
show-version fontforge --version
|
|
||||||
show-version docker --version
|
|
||||||
show-version uname -a
|
|
|
@ -10,7 +10,7 @@ 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.parent / "MonoLisa").absolute()
|
# EXTS = ["otf", "ttf", "woff", "woff2"]
|
||||||
|
|
||||||
|
|
||||||
class Color:
|
class Color:
|
||||||
|
@ -132,10 +132,9 @@ def get_args():
|
||||||
def patch_single_font(
|
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
|
display_name = f"{font_path.parent.name}/{font_path.name}"
|
||||||
rel_path = font_path.absolute().relative_to(FONT_SRC)
|
output_path = output_dir / font_path.parent.name.replace("MonoLisa/", "")
|
||||||
output_path = (output_dir / rel_path).parent
|
output_path.mkdir(exist_ok=True)
|
||||||
output_path.mkdir(exist_ok=True, parents=True)
|
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"fontforge",
|
"fontforge",
|
||||||
|
@ -145,12 +144,10 @@ def patch_single_font(
|
||||||
"./src/glyphs/",
|
"./src/glyphs/",
|
||||||
"-out",
|
"-out",
|
||||||
f"{output_path}",
|
f"{output_path}",
|
||||||
f"{font_path.absolute()}",
|
*fp_args.split(" "),
|
||||||
|
f"{font_path}",
|
||||||
]
|
]
|
||||||
|
|
||||||
if fp_args:
|
|
||||||
cmd += fp_args.split(" ")
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
echo(f"cmd: {' '.join(cmd)}")
|
echo(f"cmd: {' '.join(cmd)}")
|
||||||
run_cmd(cmd, font_path, verbose)
|
run_cmd(cmd, font_path, verbose)
|
||||||
|
@ -162,18 +159,19 @@ def patch_single_font(
|
||||||
|
|
||||||
run_cmd(cmd, font_path, verbose)
|
run_cmd(cmd, font_path, verbose)
|
||||||
|
|
||||||
echo(f"{rel_path} patched!", hue="green")
|
echo(f"{display_name} patched!", hue="green")
|
||||||
|
|
||||||
|
|
||||||
def collect_files_by_dir(fontfiles: List[Path]) -> Set[Path]:
|
def collect_files_by_dir(fontfiles: List[Path]) -> Set[Path]:
|
||||||
return set([f.parent.absolute() for f in fontfiles])
|
return set([f.parent for f in fontfiles])
|
||||||
|
|
||||||
|
|
||||||
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()
|
font_dir_path = font_dir_path.resolve()
|
||||||
output_path.mkdir(exist_ok=True, parents=True)
|
output_path = (output_dir / font_dir_path.name).resolve()
|
||||||
|
output_path.mkdir(exist_ok=True)
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
"docker",
|
"docker",
|
||||||
|
@ -186,11 +184,9 @@ def patch_font_dir_docker(
|
||||||
"-u",
|
"-u",
|
||||||
f"{os.getuid()}:{os.getegid()}",
|
f"{os.getuid()}:{os.getegid()}",
|
||||||
"nerdfonts/patcher",
|
"nerdfonts/patcher",
|
||||||
|
*fp_args.split(" "),
|
||||||
]
|
]
|
||||||
|
|
||||||
if fp_args:
|
|
||||||
cmd += 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: {' '.join(cmd)}")
|
||||||
|
@ -219,10 +215,7 @@ def main():
|
||||||
fp_args = " ".join(fp_args)
|
fp_args = " ".join(fp_args)
|
||||||
if fp_args:
|
if fp_args:
|
||||||
echo(f"Flags passed to font-patcher: {fp_args}")
|
echo(f"Flags passed to font-patcher: {fp_args}")
|
||||||
if args.verbose:
|
|
||||||
echo(f"Patching the following files")
|
|
||||||
for fontfile in args.font_path:
|
|
||||||
sys.stdout.write(f" {color.magenta}->{color.end} {fontfile}\n")
|
|
||||||
if args.docker:
|
if args.docker:
|
||||||
echo("==> DOCKER MODE ENABLED")
|
echo("==> DOCKER MODE ENABLED")
|
||||||
for font_dir in collect_files_by_dir(args.font_path):
|
for font_dir in collect_files_by_dir(args.font_path):
|
||||||
|
|
Loading…
Reference in a new issue