Compare commits

..

6 commits

Author SHA1 Message Date
56a06a32c9
fix(#4): refactor to reduce some boilerplate 2023-03-20 01:40:55 -05:00
cdb6bacf37
build: drop flake8 for ruff and update pre-commit repos 2023-03-20 01:40:55 -05:00
a8175ab675
chore: add licensing info 2023-03-20 01:40:35 -05:00
github-actions
32a93386bd
chore: change batteries 2023-03-20 01:40:35 -05:00
github-actions
04081cc370
chore: change batteries 2023-03-20 01:40:35 -05:00
github-actions
718ba2179f
chore: change batteries 2023-03-20 01:40:34 -05:00
6 changed files with 181 additions and 51 deletions

View file

@ -1,23 +1,23 @@
exclude: "^(src/.*|bin/font-patcher)"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.9.3
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.257'
hooks:
- id: flake8
- id: ruff
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2
hooks:

152
LICENSE Normal file
View file

@ -0,0 +1,152 @@
MIT License
Copyright (c) 2023 Daylin Morgan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------
See below for licensing information related to ./src/ and ./bin/font-patcher.
# Nerd Fonts Licensing
There are various sources used under various licenses:
* Nerd Fonts source fonts, patched fonts, and folders with explict OFL SIL files are licensed under SIL OPEN FONT LICENSE Version 1.1 (see below).
* Nerd Fonts original source code files (such as `.sh`, `.py`, `font-patcher` and others) are licensed under the MIT License (MIT) (see below).
* Many other licenses are present in this project for even more detailed breakdown see: [License Audit](https://github.com/ryanoasis/nerd-fonts/blob/-/license-audit.md).
## Source files not in folders containing an explicit license are using the MIT License (MIT)
The MIT License (MIT)
Copyright (c) 2014 Ryan L McIntyre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## Various Fonts, Patched Fonts, SVGs, Glyph Fonts, and any files in a folder with explicit SIL OFL 1.1 License
Copyright (c) 2014, Ryan L McIntyre (https://ryanlmcintyre.com).
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View file

@ -1,13 +1,10 @@
-include .env
ARGS ?= -c
NF_SRC := $(shell ./bin/get-font-files src)
FONT_FLAGS := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2')
patch: ./bin/font-patcher ## apply nerd fonts patch |> -gs b_magenta -ms bold
@./bin/patch-monolisa \
$(FONT_FLAGS) \
$(ARGS)
@./patch-monolisa \
$(ARGS) \
-f MonoLisa/
update-fonts: ## move fonts and update fc-cache
$(call msg,Adding Fonts To System)

View file

@ -11,7 +11,7 @@ tested w/ MonoLisa v2.003
## Dependencies
- `python`
- `make`
- `make` (optional)
- `fontforge` OR `docker`
@ -52,7 +52,7 @@ you can easily apply the nerd font patches with `make`.
To patch all font types use the default `patch` rule.
```bash
make
make # or ./patch-monolisa -f MonoLisa -c
```
By default the complete (`-c`) flag is passed to the font-patcher script to include all icons/symbols.
@ -62,7 +62,7 @@ You can change this by specifying the `ARGS` at runtime.
ARGS="-c -w" make patch
```
See `./bin/patch-monolisa --help` and `./bin/font-patcher --help` for available `ARGS`.
See `./patch-monolisa --help` and `./bin/font-patcher --help` for available `ARGS`.
You can find your patched fonts in the `patched/` directory

View file

@ -1,30 +0,0 @@
#!/usr/bin/env python3
import sys
from pathlib import Path
EXTS = ["otf", "ttf", "woff", "woff2"]
def find_files(search_path, exts=None):
return (
[f for ext in exts for f in search_path.glob(f"**/*.{ext}")]
if exts
else [f for f in search_path.rglob("*") if f.is_file()]
)
def main():
if len(sys.argv) == 1:
print("please specify directory to search")
exit(1)
search_path = Path(sys.argv[1])
exts = sys.argv[2].split(",") if len(sys.argv) == 3 else EXTS
for f in find_files(search_path, exts):
sys.stdout.write(f"-f '{f}' ")
if __name__ == "__main__":
main()

View file

@ -10,7 +10,7 @@ import time
from pathlib import Path
from typing import List, Set
FONT_SRC = (Path(__file__).parent.parent / "MonoLisa").absolute()
FONT_SRC = (Path(__file__).parent / "MonoLisa").absolute()
class Color:
@ -159,7 +159,6 @@ def patch_single_font(
f"{color.yellow}:::{color.end} Patching font "
f"{color.bold}{font_path.name}{color.end}... "
):
run_cmd(cmd, font_path, verbose)
echo(f"{rel_path} patched!", hue="green")
@ -205,6 +204,17 @@ def patch_font_dir_docker(
echo(f"{font_dir_path.name}/ fonts patched!", hue="green")
def get_font_files(p):
exts = ["otf", "ttf", "woff", "woff2"]
if p.is_file():
return (p,)
if p.is_dir():
return (f for ext in exts for f in p.glob(f"**/*.{ext}"))
return ()
def echo(msg: str, header=False, hue="cyan") -> None:
if header:
print(f"==>{color.magenta} {msg} {color.end}<==")
@ -213,7 +223,6 @@ def echo(msg: str, header=False, hue="cyan") -> None:
def main():
echo("MonoLisa NerdFont Patcher", header=True)
args, fp_args = get_args()
fp_args = " ".join(fp_args)
@ -223,12 +232,15 @@ def main():
echo("Patching the following files")
for fontfile in args.font_path:
sys.stdout.write(f" {color.magenta}->{color.end} {fontfile}\n")
fontfiles = [f for p in args.font_path for f in get_font_files(p)]
if args.docker:
echo("==> DOCKER MODE ENABLED")
for font_dir in collect_files_by_dir(args.font_path):
for font_dir in collect_files_by_dir(fontfiles):
patch_font_dir_docker(font_dir, args.output, fp_args, args.verbose)
else:
for fontfile in args.font_path:
for fontfile in fontfiles:
patch_single_font(Path(fontfile), args.output, fp_args, args.verbose)
echo("fonts are patched", hue="green")
@ -236,6 +248,5 @@ def main():
if __name__ == "__main__":
color = Color()
main()