Skip to content

Commit 736940c

Browse files
authored
Merge pull request #1 from saltcandy123/develop
Add prototype
2 parents 52430e9 + 6a2fec4 commit 736940c

118 files changed

Lines changed: 4185 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/github-pages.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- v[0-9]+.[0-9]+.[0-9]+
8+
9+
jobs:
10+
build:
11+
name: Build GitHub Pages
12+
# Ubuntu 20.04 or later is required for python3-fontforge
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: '14'
19+
- name: Install FontForge
20+
run: sudo apt-get install fontforge python3-fontforge
21+
- name: Build fonts
22+
run: python3 build_fonts.py --tag ${{ github.sha }}
23+
- name: Build webapp
24+
run: |
25+
export NEXTJS_BASE_PATH=$(echo $GITHUB_REPOSITORY | sed -e 's@.*/\(.*\)@\/\1@')
26+
cd webapp
27+
yarn
28+
yarn run build
29+
- name: Add miscellaneous files into /webapp-dist
30+
run: |
31+
cd webapp-dist/
32+
touch .nojekyll
33+
fontimage ../font-dist/saltcandy123font.ttf -o sample.png
34+
- name: Publish GitHub Pages
35+
run: |
36+
mv .git webapp-dist/
37+
cd webapp-dist/
38+
git checkout --orphan gh-pages
39+
git add .
40+
git config user.email "saltcandy123@gmail.com"
41+
git config user.name "saltcandy123 (GitHub Actions)"
42+
git commit -m 'publish GitHub Pages (source commit: ${{ github.sha }})'
43+
git push origin gh-pages -f

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.[0-9]+.[0-9]+
7+
8+
jobs:
9+
build-font:
10+
name: Build fonts
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Install FontForge
15+
run: sudo apt-get install fontforge python3-fontforge
16+
- name: Build fonts
17+
run: python3 build_fonts.py --tag ${{ github.ref }}
18+
- name: Create release
19+
id: create_release
20+
uses: actions/create-release@v1
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
tag_name: ${{ github.ref }}
25+
release_name: ${{ github.ref }}
26+
- name: Upload saltcandy123font.ttf
27+
uses: actions/upload-release-asset@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
upload_url: ${{ steps.create_release.outputs.upload_url }}
32+
asset_path: font-dist/saltcandy123font.ttf
33+
asset_name: saltcandy123font.ttf
34+
asset_content_type: font/ttf
35+
- name: Upload saltcandy123font.woff
36+
uses: actions/upload-release-asset@v1
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
with:
40+
upload_url: ${{ steps.create_release.outputs.upload_url }}
41+
asset_path: font-dist/saltcandy123font.woff
42+
asset_name: saltcandy123font.woff
43+
asset_content_type: font/woff
44+
- name: Upload saltcandy123font.woff2
45+
uses: actions/upload-release-asset@v1
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
with:
49+
upload_url: ${{ steps.create_release.outputs.upload_url }}
50+
asset_path: font-dist/saltcandy123font.woff2
51+
asset_name: saltcandy123font.woff2
52+
asset_content_type: font/woff2

.github/workflows/verification.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Verification
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build fonts and demo pages
12+
# Ubuntu 20.04 or later is required for python3-fontforge
13+
runs-on: ubuntu-20.04
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: '14'
19+
- name: Lint glyph SVG files
20+
run: |
21+
python3 utils/clean_glyphs.py glyphs/
22+
git diff --numstat --exit-code
23+
- name: Install FontForge
24+
run: sudo apt-get install fontforge python3-fontforge
25+
- name: Build fonts
26+
run: python3 build_fonts.py --tag ${{ github.sha }}
27+
- name: Archive font-dist
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: font-dist
31+
path: font-dist
32+
- name: Build webapp
33+
run: |
34+
cd webapp
35+
yarn
36+
yarn run lint
37+
yarn run build
38+
- name: Archive webapp-dist
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: webapp-dist
42+
path: webapp-dist
43+
super-linter:
44+
name: Run Super-Linter
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: Run Super-Linter
49+
uses: github/super-linter@v3
50+
env:
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
FILTER_REGEX_EXCLUDE: .*/glyphs/.*|.*/webapp/.*\.(jsx?|tsx?)

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.next
3+
/font-dist
4+
/webapp-dist
5+
yarn-error.log

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
# saltcandy123font
2-
A simple handwritten font created by @saltcandy123
2+
3+
@saltcandy123 による手書きフォントです。
4+
5+
This is a simple handwritten font created by @saltcandy123.
6+
7+
* Download font from <https://github.com/saltcandy123/saltcandy123font/releases>
8+
* Try out demo on <https://saltcandy123.github.io/saltcandy123font/>
9+
10+
![Sample image](https://saltcandy123.github.io/saltcandy123font/sample.png)
11+
12+
## How it works
13+
14+
All the glyph data is stored as SVG files in [`/glyphs`](./glyphs) directory.
15+
Each SVG file is named after the corresponding 4-digit hex Unicode.
16+
For instance, the filename for "A" glyph should be [`u0041.svg`](./glyphs/u0041.svg) because the Unicode of "A" is 41 in hex.
17+
See also [Unicode Character Code Charts](https://unicode.org/charts/).
18+
19+
A Python script [`/build_fonts.py`](./build_fonts.py) converts the SVG files to fonts in `/font-dist` directory.
20+
It requires [FontForge](https://fontforge.org/) and [its Python library](https://fontforge.org/docs/scripting/python.html).
21+
22+
[`/webapp`](./webapp) is the source code directory for <https://saltcandy123.github.io/saltcandy123font/>.
23+
`yarn && yarn build` builds static pages in `/webapp-dist` directory.
24+
`yarn build` requires `/font-dist` directory with font files.
25+
26+
Releasing is handled by GitHub Actions.
27+
By pushing a tag to this repository, GitHub Actions will automatically [create a new release](./.github/workflows/release.yml) and [update GitHub Pages](./.github/workflows/github-pages.yml).

build_fonts.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import pathlib
5+
import re
6+
import xml.dom.minidom
7+
8+
import fontforge
9+
10+
BASE_DIR = pathlib.Path(__file__).parent
11+
12+
13+
def build_saltcandy123font(*, tag):
14+
font = fontforge.font()
15+
font.familyname = "saltcandy123font"
16+
font.fullname = "saltcandy123font-Regular"
17+
font.fontname = font.fullname
18+
font.copyright = "Copyright (C) saltcandy123"
19+
font.weight = "Regular"
20+
font.os2_weight = 400
21+
if tag:
22+
font.version = tag
23+
24+
for svg_path in BASE_DIR.joinpath("glyphs").iterdir():
25+
match = re.search("^u([0-9a-f]{4}).svg$", svg_path.name)
26+
if not match:
27+
continue
28+
code = int(match.group(1), 16)
29+
glyph = font.createChar(code)
30+
glyph.importOutlines(str(svg_path))
31+
with xml.dom.minidom.parse(str(svg_path)) as doc:
32+
glyph.width = int(doc.childNodes[0].getAttribute("width"))
33+
return font
34+
35+
36+
def main():
37+
parser = argparse.ArgumentParser()
38+
parser.add_argument("--tag")
39+
args = parser.parse_args()
40+
41+
dist_dir = BASE_DIR.joinpath("font-dist")
42+
dist_dir.mkdir(exist_ok=True)
43+
44+
font_map = {
45+
"saltcandy123font": build_saltcandy123font(tag=args.tag),
46+
}
47+
for font_name in font_map:
48+
font = font_map[font_name]
49+
for ext in ["ttf", "woff", "woff2"]:
50+
font.generate(str(dist_dir.joinpath(f"{font_name}.{ext}")))
51+
52+
53+
if __name__ == "__main__":
54+
main()

glyphs/u0020.svg

Lines changed: 4 additions & 0 deletions
Loading

glyphs/u0021.svg

Lines changed: 5 additions & 0 deletions
Loading

glyphs/u0022.svg

Lines changed: 5 additions & 0 deletions
Loading

glyphs/u0023.svg

Lines changed: 7 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)