From f084bb0d1bed87a23b0148623d4d3c3bf3a8d725 Mon Sep 17 00:00:00 2001 From: Mark Joshwel Date: Thu, 4 Jul 2024 00:04:26 +0800 Subject: [PATCH] better docs --- .idea/vcs.xml | 6 ++++ README.md | 44 +++++++++++++++++++++---- extract.png => extract-7zip-example.png | 0 extract-terminal-example.png | 3 ++ extract.py | 28 ++++++++++++++-- 5 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 .idea/vcs.xml rename extract.png => extract-7zip-example.png (100%) create mode 100644 extract-terminal-example.png diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 1176ac8..b1bb4bf 100644 --- a/README.md +++ b/README.md @@ -2,25 +2,57 @@ a collection of fonts that are licenced under the Open Font Licence -**except for**: +**except for** - `sources/JohnnyGLTFont.zip` by u/JohnnyDZ0707 [(link)](https://old.reddit.com/r/GirlsLastTour/comments/e5wprz/i_made_a_font_link_in_comments_english_numbers/) +## instructions + steps to extract everything from the zip files: +> [!NOTE] +> tips for windows users: +> +> - when extracting, you can select all the zip files via clicking on `Type` to sort by type, then selecting all the zip files + + 1. extract every `sources/*.zip` to `sources/ext/*` for windows: select everything in sources, right click, `Extract files...` (7-zip) modify the path to add a `ext/` after `sources/` - ![instructions](extract.png) + ![instructions](extract-7zip-example.png) 2. run `python extract.py` - this will extract all the fonts to `files/` + this will extract all the fonts to `files/` + + for windows users or non-power users: + - right-click in the newly created `fonts` folder + - right-click, and click on `Open in Terminal` + - then, type out '`python extract.py`' (without the single quotes btw) within the black box + - press enter to run it -tips for windows users: + ![example](extract-terminal-example.png) -- when extracting, you can select all the zip files via clicking on `Type` to sort by type, then selecting all the zip files -- inside the new `files` folder, you can select all the fonts, right click, and `Install` or `Install for all users` + if you get an error, you might need to install python from [here](https://www.python.org/downloads/) + +3. install the fonts in `files/` + + - **for windows** + select all the fonts, right-click, `Install` or `Install for all users` + + - **for mac** + copy the fonts to `~/Library/Fonts/` + + - **for Plan9 or 9front** + copy the fonts to `/lib/font/bit/` after converting them with + + - **for bsds** + copy the fonts to `~/.fonts/` or `/usr/local/share/fonts/` + + - **for linux** + copy the fonts to `~/.local/share/fonts/`, `/usr/share/fonts/`, or `/usr/local/share/fonts/` + + for *nix systems, you can also use a font manager if you prefer diff --git a/extract.png b/extract-7zip-example.png similarity index 100% rename from extract.png rename to extract-7zip-example.png diff --git a/extract-terminal-example.png b/extract-terminal-example.png new file mode 100644 index 0000000..ac45b93 --- /dev/null +++ b/extract-terminal-example.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d98f45791a6fbef72bbc70e65277aa53291b663b7db76354eee7fabe3088e2d +size 38834 diff --git a/extract.py b/extract.py index 87cd73e..613677f 100644 --- a/extract.py +++ b/extract.py @@ -2,6 +2,9 @@ from pathlib import Path from shutil import copy2 +from sys import argv +from shutil import get_terminal_size + # sources: source font zip files are # sources/ext: extracted content of source/*.zip @@ -27,19 +30,40 @@ def main(): pre_exists: bool = PRE_DIR.exists() tracking: list[str] = [] + # get terminal size, if possible + col: int = 0 + lns: int = 0 + try: + col, lns = get_terminal_size() + except Exception: + col, lns = 0, 0 + # recursively iterate through SOURCES_EXT_DIR for path in SOURCES_EXT_DIR.rglob('*'): # if it is an otf or ttf file, copy just the file to FILES_DIR if path.is_file() and path.suffix in ['.otf', '.ttf']: + # if the file starts with a dot, skip + if path.stem.startswith('.'): + if "-v" in argv: + print(f"{path.relative_to(SOURCES_DIR)} (skipped)") + continue + # if we already copied either its otf or ttf counterpart, skip if path.stem in tracking: - print(f"{path} (skipped)") + continue else: tracking.append(path.stem) dest = FILES_DIR.joinpath(path.name) copy2(path, dest) - print(f"{path} -> {dest}") + + # print 'path' and 'dest' in a short format + if "-v" in argv: + print(f"{str(path.relative_to(SOURCES_DIR.parent))} -> {str(dest.relative_to(FILES_DIR.parent))}") + else: + print(f"\r{str(dest.relative_to(FILES_DIR.parent)).ljust(col)}", end="") + else: + print() # if PRE_DIR exists, recursively iterate through it and then see # what files in the PRE_DIR are not in PRE_DIR