mirror of
https://github.com/cupcakearmy/glyphance.git
synced 2025-09-05 22:10:39 +00:00
Compare commits
12 Commits
v1.0.0-rc.
...
v1.0.2
Author | SHA1 | Date | |
---|---|---|---|
7f1fdbcc49 | |||
6f62afef11 | |||
4c47745b51 | |||
572df17230 | |||
5ce24c9879 | |||
dff88c5bb7 | |||
92a53c0c62 | |||
a77f6f1c06 | |||
15566d5299 | |||
61d4f0e52e | |||
fdf0c137f8 | |||
853fad31de |
@@ -1,5 +1,4 @@
|
||||
*
|
||||
!src
|
||||
!poetry.lock
|
||||
!poetry.toml
|
||||
!pyproject.toml
|
||||
|
@@ -8,8 +8,8 @@ ENV PATH ${POETRY_HOME}/bin:$PATH
|
||||
|
||||
# Install Deps
|
||||
WORKDIR /app
|
||||
COPY poetry.lock poetry.toml pyproject.toml ./
|
||||
RUN poetry install
|
||||
COPY poetry.lock pyproject.toml ./
|
||||
RUN poetry install --no-cache --without dev --sync
|
||||
|
||||
# Copy code
|
||||
COPY . .
|
||||
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Niccolo Borgioli
|
||||
|
||||
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.
|
3
Makefile
3
Makefile
@@ -5,3 +5,6 @@ jsonschema:
|
||||
pnpm dlx @adobe/jsonschema2md --input tmp --out docs/config
|
||||
rm -r out
|
||||
rm -r tmp
|
||||
|
||||
docker:
|
||||
docker build -t glyphance .
|
||||
|
48
README.md
48
README.md
@@ -1,12 +1,20 @@
|
||||
# Glyphance
|
||||
|
||||
This is a CLI utility that help reduce load times and bytes by splitting typography files into smaller chunks for different alphabets automatically _without the tears_.
|
||||
<kbd>/ɡlɪfhɑːns/</kdb>
|
||||
|
||||
This is a CLI utility that help reduce load times and bytes by splitting typography files into smaller chunks for different unicode ranges automatically _without the tears_.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## 🌈 Features
|
||||
|
||||
- Configurable.
|
||||
- Config driven.
|
||||
- Docker image, no install required.
|
||||
- Docker image, no local install required.
|
||||
- Outputs `woff2`.
|
||||
- Provides a generated CSS file to simply include.
|
||||
|
||||
## 🚀 Quickstart
|
||||
|
||||
@@ -51,12 +59,14 @@ output:
|
||||
### Run
|
||||
|
||||
```bash
|
||||
docker run -v $(pwd)/example:/data glyphance
|
||||
docker run -v $(pwd)/example:/data cupcakearmy/glyphance
|
||||
```
|
||||
|
||||
### Enjoy
|
||||
|
||||
Now you can use the generated font files and the `generated/fonts.css`.
|
||||
Now you can use the generated font files and import the `generated/fonts.css` into your code.
|
||||
|
||||
> Remember you can modify the `prefix` to match the folder structure of your static files.
|
||||
|
||||
```
|
||||
example/
|
||||
@@ -99,3 +109,33 @@ output:
|
||||
css:
|
||||
font-weight: 400 # CSS to added to each @font-face. By defaults includes swap, normal weight and style
|
||||
```
|
||||
|
||||
### Provide custom unicode ranges
|
||||
|
||||
By default Glyphance uses the same ranges as Google Fonts. However you can customize and specify your own ranges. See the [list of possible values](https://en.wikipedia.org/wiki/List_of_Unicode_characters).
|
||||
|
||||
```yaml
|
||||
fonts:
|
||||
'Mulish':
|
||||
- file: Mulish-VariableFont_wght.ttf
|
||||
variable: true
|
||||
css:
|
||||
font-weight: 200 1000
|
||||
- file: Mulish-Italic-VariableFont_wght.ttf
|
||||
variable: true
|
||||
css:
|
||||
font-weight: 200 1000
|
||||
font-style: italic
|
||||
'FireCode':
|
||||
- file: FiraCode-VariableFont_wght.ttf
|
||||
variable: true
|
||||
css:
|
||||
font-weight: 300 700
|
||||
|
||||
output:
|
||||
ranges:
|
||||
abc: U+0061-0063
|
||||
numbers: U+0030-0039
|
||||
dot: U+002E
|
||||
""
|
||||
```
|
||||
|
32
poetry.lock
generated
32
poetry.lock
generated
@@ -53,7 +53,7 @@ cffi = ">=1.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2022.9.24"
|
||||
version = "2022.12.7"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
category = "main"
|
||||
optional = false
|
||||
@@ -156,7 +156,7 @@ python-versions = ">=3.5"
|
||||
|
||||
[[package]]
|
||||
name = "jsonschema"
|
||||
version = "4.17.0"
|
||||
version = "4.17.3"
|
||||
description = "An implementation of JSON Schema validation for Python"
|
||||
category = "main"
|
||||
optional = false
|
||||
@@ -213,7 +213,7 @@ python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pycodestyle"
|
||||
version = "2.9.1"
|
||||
version = "2.10.0"
|
||||
description = "Python style guide checker"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -263,7 +263,7 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
|
||||
|
||||
[[package]]
|
||||
name = "setuptools"
|
||||
version = "65.6.0"
|
||||
version = "65.6.3"
|
||||
description = "Easily download, build, install, upgrade, and uninstall Python packages"
|
||||
category = "main"
|
||||
optional = false
|
||||
@@ -311,11 +311,11 @@ testing = ["coverage", "pytest", "pytest-randomly", "pytest-xdist"]
|
||||
|
||||
[[package]]
|
||||
name = "urllib3"
|
||||
version = "1.26.12"
|
||||
version = "1.26.13"
|
||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4"
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"]
|
||||
@@ -468,8 +468,8 @@ brotlicffi = [
|
||||
{file = "brotlicffi-1.0.9.2.tar.gz", hash = "sha256:0c248a68129d8fc6a217767406c731e498c3e19a7be05ea0a90c3c86637b7d96"},
|
||||
]
|
||||
certifi = [
|
||||
{file = "certifi-2022.9.24-py3-none-any.whl", hash = "sha256:90c1a32f1d68f940488354e36370f6cca89f0f106db09518524c88d6ed83f382"},
|
||||
{file = "certifi-2022.9.24.tar.gz", hash = "sha256:0d9c601124e5a6ba9712dbc60d9c53c21e34f5f641fe83002317394311bdce14"},
|
||||
{file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
|
||||
{file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
|
||||
]
|
||||
cffi = [
|
||||
{file = "cffi-1.15.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2"},
|
||||
@@ -562,8 +562,8 @@ idna = [
|
||||
{file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"},
|
||||
]
|
||||
jsonschema = [
|
||||
{file = "jsonschema-4.17.0-py3-none-any.whl", hash = "sha256:f660066c3966db7d6daeaea8a75e0b68237a48e51cf49882087757bb59916248"},
|
||||
{file = "jsonschema-4.17.0.tar.gz", hash = "sha256:5bfcf2bca16a087ade17e02b282d34af7ccd749ef76241e7f9bd7c0cb8a9424d"},
|
||||
{file = "jsonschema-4.17.3-py3-none-any.whl", hash = "sha256:a870ad254da1a8ca84b6a2905cac29d265f805acc57af304784962a2aa6508f6"},
|
||||
{file = "jsonschema-4.17.3.tar.gz", hash = "sha256:0f864437ab8b6076ba6707453ef8f98a6a0d512a80e93f8abdb676f737ecb60d"},
|
||||
]
|
||||
lxml = [
|
||||
{file = "lxml-4.9.1-cp27-cp27m-macosx_10_15_x86_64.whl", hash = "sha256:98cafc618614d72b02185ac583c6f7796202062c41d2eeecdf07820bad3295ed"},
|
||||
@@ -674,8 +674,8 @@ mypy-extensions = [
|
||||
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
|
||||
]
|
||||
pycodestyle = [
|
||||
{file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"},
|
||||
{file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"},
|
||||
{file = "pycodestyle-2.10.0-py2.py3-none-any.whl", hash = "sha256:8a4eaf0d0495c7395bdab3589ac2db602797d76207242c17d470186815706610"},
|
||||
{file = "pycodestyle-2.10.0.tar.gz", hash = "sha256:347187bdb476329d98f695c213d7295a846d1152ff4fe9bacb8a9590b8ee7053"},
|
||||
]
|
||||
pycparser = [
|
||||
{file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"},
|
||||
@@ -752,8 +752,8 @@ requests = [
|
||||
{file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"},
|
||||
]
|
||||
setuptools = [
|
||||
{file = "setuptools-65.6.0-py3-none-any.whl", hash = "sha256:6211d2f5eddad8757bd0484923ca7c0a6302ebc4ab32ea5e94357176e0ca0840"},
|
||||
{file = "setuptools-65.6.0.tar.gz", hash = "sha256:d1eebf881c6114e51df1664bc2c9133d022f78d12d5f4f665b9191f084e2862d"},
|
||||
{file = "setuptools-65.6.3-py3-none-any.whl", hash = "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54"},
|
||||
{file = "setuptools-65.6.3.tar.gz", hash = "sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
@@ -822,8 +822,8 @@ unicodedata2 = [
|
||||
{file = "unicodedata2-15.0.0.tar.gz", hash = "sha256:ed6c683f7b0a58cd11824b440d8ad24b22904ab3f63fc851bbcd7e518fa68f2d"},
|
||||
]
|
||||
urllib3 = [
|
||||
{file = "urllib3-1.26.12-py2.py3-none-any.whl", hash = "sha256:b930dd878d5a8afb066a637fbb35144fe7901e3b209d1cd4f524bd0e9deee997"},
|
||||
{file = "urllib3-1.26.12.tar.gz", hash = "sha256:3fa96cf423e6987997fc326ae8df396db2a8b7c667747d47ddd8ecba91f4a74e"},
|
||||
{file = "urllib3-1.26.13-py2.py3-none-any.whl", hash = "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc"},
|
||||
{file = "urllib3-1.26.13.tar.gz", hash = "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"},
|
||||
]
|
||||
zopfli = [
|
||||
{file = "zopfli-0.2.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e340851bbdea91408e6713748b4082c2e464a80eef9f9a69ff5a20e5e008cace"},
|
||||
|
@@ -1,2 +0,0 @@
|
||||
[virtualenvs]
|
||||
in-project = true
|
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "glyphance"
|
||||
version = "0.1.0"
|
||||
version = "1.0.2"
|
||||
description = ""
|
||||
authors = ["Niccolo Borgioli <hi@nicco.io>"]
|
||||
license = "MIT"
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
|
||||
import click
|
||||
import jsonschema
|
||||
import yaml
|
||||
|
||||
@@ -31,9 +32,17 @@ def validate(config):
|
||||
|
||||
def load(path):
|
||||
# Load config
|
||||
path = os.path.abspath(path)
|
||||
with open(path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
try:
|
||||
path = os.path.abspath(path)
|
||||
with open(path, 'r') as f:
|
||||
config = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
click.echo(f"Config file not found: {path}")
|
||||
exit(1)
|
||||
except yaml.YAMLError as e:
|
||||
click.echo(f"Config file is not valid YAML: {path}")
|
||||
click.echo(e)
|
||||
exit(1)
|
||||
|
||||
# Setting dynamic defaults
|
||||
default_config['context'] = os.path.dirname(path)
|
||||
|
@@ -8,7 +8,7 @@ from config import load, validate
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.version_option("0.1.0")
|
||||
@click.version_option("1.0.0")
|
||||
@click.option('-v', '--verbose', is_flag=True, default=False, help="Run in verbose mode.")
|
||||
@click.option('-c', '--config', type=click.Path(), required=True, help="Path to the config file.")
|
||||
@click.option('-o', '--output-directory', type=click.Path(), help="Path to the output directory.")
|
||||
|
Reference in New Issue
Block a user