11 Commits

Author SHA1 Message Date
6f62afef11 Merge branch 'main' of https://github.com/cupcakearmy/glyphance 2022-11-27 01:18:03 +01:00
4c47745b51 update dependencies 2022-11-27 01:18:01 +01:00
572df17230 version bump 2022-11-27 01:14:53 +01:00
5ce24c9879 docker build 2022-11-27 01:14:47 +01:00
dff88c5bb7 reduce docker image size 2022-11-27 01:14:41 +01:00
92a53c0c62 delete poetry config 2022-11-27 01:14:32 +01:00
a77f6f1c06 error handling on config load 2022-11-27 01:14:24 +01:00
15566d5299 Create LICENSE 2022-11-26 18:36:48 +01:00
61d4f0e52e add badges because cool 2022-11-21 17:33:23 +01:00
fdf0c137f8 readme 2022-11-21 17:27:42 +01:00
853fad31de bump version 2022-11-21 16:28:56 +01:00
10 changed files with 97 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
*
!src
!poetry.lock
!poetry.toml
!pyproject.toml

View File

@@ -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
View 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.

View File

@@ -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 .

View File

@@ -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_.
![Docker Image Version (latest semver)](https://img.shields.io/docker/v/cupcakearmy/glyphance?sort=semver&style=flat-square)
![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/cupcakearmy/glyphance?sort=semver&style=flat-square)
![Docker Pulls](https://img.shields.io/docker/pulls/cupcakearmy/glyphance?style=flat-square)
## 🌈 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
""
```

26
poetry.lock generated
View File

@@ -156,7 +156,7 @@ python-versions = ">=3.5"
[[package]]
name = "jsonschema"
version = "4.17.0"
version = "4.17.1"
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)"]
@@ -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.1-py3-none-any.whl", hash = "sha256:410ef23dcdbca4eaedc08b850079179883c2ed09378bd1f760d4af4aacfa28d7"},
{file = "jsonschema-4.17.1.tar.gz", hash = "sha256:05b2d22c83640cde0b7e0aa329ca7754fbd98ea66ad8ae24aa61328dfe057fa3"},
]
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"},

View File

@@ -1,2 +0,0 @@
[virtualenvs]
in-project = true

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "glyphance"
version = "0.1.0"
version = "1.0.1"
description = ""
authors = ["Niccolo Borgioli <hi@nicco.io>"]
license = "MIT"

View File

@@ -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)

View File

@@ -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.")