-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from saltcandy123/develop
Add npm-publish automation and remove webapp
- Loading branch information
Showing
28 changed files
with
238 additions
and
3,802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
name: Font image | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build-font: | ||
name: Update font image | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install FontForge | ||
run: sudo apt-get install fontforge python3-fontforge | ||
- name: Build fonts | ||
run: python3 build_font.py ${{ github.sha }} | ||
- name: Update font image | ||
run: bash update-fontimage.sh | ||
- name: Push the update to GitHub | ||
run: | | ||
git config user.email "saltcandy123@gmail.com" | ||
git config user.name "saltcandy123 (GitHub Actions)" | ||
git add fontimage.png | ||
if git commit -m 'Update font image'; then | ||
git push origin | ||
else | ||
echo No change on fontimage.png | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1 @@ | ||
node_modules | ||
.next | ||
/font-dist | ||
/webapp-dist | ||
yarn-error.log | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# saltcandy123font | ||
|
||
This is a simple handwritten font created by @saltcandy123. | ||
|
||
![Font image](https://raw.githubusercontent.com/saltcandy123/saltcandy123font/main/fontimage.png) | ||
|
||
## Usage | ||
|
||
Install the package. | ||
|
||
```bash | ||
# npm | ||
npm i @saltcandy123/saltcandy123font | ||
|
||
# yarn | ||
yarn add @saltcandy123/saltcandy123font | ||
``` | ||
|
||
Then, use `saltcandy123font.ttf` or `saltcandy123font.woff` in your frontend code. | ||
|
||
```javascript | ||
import saltcandy123font from '@saltcandy123/saltcandy123font/saltcandy123font.woff'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python3 | ||
|
||
"""Build saltcandy123font from SVG files""" | ||
|
||
import argparse | ||
import json | ||
import pathlib | ||
import re | ||
import xml.dom.minidom | ||
|
||
import fontforge | ||
|
||
BASE_DIR = pathlib.Path(__file__).parent | ||
|
||
|
||
def build_saltcandy123font(*, version: str) -> fontforge.font: | ||
font = fontforge.font() | ||
font.fontname = "saltcandy123font" | ||
font.fullname = font.fontname | ||
font.familyname = font.fontname | ||
font.copyright = "Copyright (C) saltcandy123" | ||
font.weight = "Regular" | ||
font.os2_weight = 400 | ||
font.version = version | ||
|
||
for svg_path in BASE_DIR.joinpath("glyphs").iterdir(): | ||
match = re.search("^u([0-9a-f]{4}).svg$", svg_path.name) | ||
if not match: | ||
continue | ||
code = int(match.group(1), 16) | ||
glyph = font.createChar(code) | ||
glyph.importOutlines(str(svg_path)) | ||
with xml.dom.minidom.parse(str(svg_path)) as doc: | ||
glyph.width = int(doc.childNodes[0].getAttribute("width")) | ||
|
||
return font | ||
|
||
|
||
def generate_npm_package_metadata(*, version=str) -> dict: | ||
return { | ||
"name": "@saltcandy123/saltcandy123font", | ||
"version": version, | ||
"description": "A simple handwritten font created by @saltcandy123", | ||
"repository": "https://github.com/saltcandy123/saltcandy123font", | ||
"author": "saltcandy123", | ||
} | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument("font_version", help="font version (e.g. 0.1.2)") | ||
args = parser.parse_args() | ||
|
||
dist_dir = BASE_DIR.joinpath("dist") | ||
dist_dir.mkdir(exist_ok=True) | ||
|
||
font = build_saltcandy123font(version=args.font_version) | ||
|
||
for ext in ["ttf", "woff"]: | ||
font.generate(str(dist_dir.joinpath(f"saltcandy123font.{ext}"))) | ||
|
||
package_metadata = generate_npm_package_metadata(version=args.font_version) | ||
with open(dist_dir.joinpath("package.json"), "w") as f: | ||
json.dump(package_metadata, f, indent=2) | ||
|
||
with open(dist_dir.joinpath("README.md"), "w") as f: | ||
with open(BASE_DIR.joinpath("README-npm.md")) as f_src: | ||
f.write(f_src.read()) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.