Skip to content

Commit

Permalink
2024/04/16#3
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-212 committed Apr 16, 2024
1 parent 606cc07 commit b2cf7f5
Show file tree
Hide file tree
Showing 269 changed files with 6,047 additions and 7,838 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build_fonts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Builds fonts either when a prerelease version tag (e.g. v1.2-foo)
# is created, or when source is changed.
#
# When a version tag is created, a pre-release is automatically created.
#
# Otherwise, when source changes without a tag being created,
# the build artifacts are uploaded to github and saved for 1 day.
# They can be found at https://github.com/rsms/inter/actions/runs/RUNID
name: Build fonts

on:
push:
branches: [main]
paths:
- "src/**"
- "scripts/**"
- Makefile
- requirements.txt
tags:
- "v*"
pull_request:
branches: [main]
paths:
- "src/**"
- "scripts/**"
- Makefile
- requirements.txt
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install utilities
run: sudo apt-get install -y zip

- name: make init
run: make init

- name: Define version (tag)
if: startsWith(github.ref, 'refs/tags/v')
run: |
VERSION=${{ github.ref }}
VERSION=${VERSION:11} # refs/tags/v1.2.3 => 1.2.3
echo "NeoHanSans_version=$VERSION" >> $GITHUB_ENV
- name: Define version (branch)
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
run: |
python misc/scripts/get_ver.py
GITSHA=${{ github.sha }}
VERSION=$(cat version.txt)
echo "NeoHanSans_version=${VERSION}-${GITSHA:0:7}" >> $GITHUB_ENV
- name: make build
run: |
ZIP=NeoHanSans-${{ env.NeoHanSans_version }}.zip
echo "NeoHanSans_zip=$ZIP" >> $GITHUB_ENV
make zip
mv NeoHanSans.zip "$ZIP"
- name: Upload archive (unless tag)
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: "${{ env.NeoHanSans_version }}"
path: ${{ env.NeoHanSans_zip }}
retention-days: 1

- name: Create release (if tag)
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
prerelease: true
name: "${{ env.NeoHanSans_version }}"
body: "This release was created automatically"
files: ${{ env.NeoHanSans_zip }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.DS_STORE
src/NeoHanSans-Variable(自动存储).glyphspackage
src/NeoHanSans-Variable(自动存储).glyphspackage
fonts
fonts-temp
version.txt
*.stamp
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
help:
@echo "###"
@echo "# Build targets for Neo Han Sans SC"
@echo "###"
@echo
@echo " make build: Builds the fonts and places them in the fonts/ directory"
@echo " make zip: Zip all fonts into a zip"
@echo

init: requirements.txt
pip install -Ur requirements.txt
touch init.stamp

build: build.stamp

# fontmake -m "fonts-temp/master-ufo/InterNumeric.designspace" -o variable --output-path "fonts/variable/InterNumeric[wght,RDNS].ttf" --filter DecomposeTransformedComponentsFilter --verbose DEBUG
# fontmake -m "fonts-temp/master-ufo/InterNumeric.designspace" -o variable-cff2 --output-path "fonts/variable/InterNumeric[wght,RDNS].otf"


build.stamp: init.stamp
fontmake -g "src/NeoHanSans-Variable.glyphspackage" -o variable --output-path "fonts/variable/NeoHanSansSC[wght].ttf"
python scripts/stat.py
touch build.stamp

zip: build.stamp
cp -rf fonts NeoHanSansSC
zip -r NeoHanSans.zip NeoHanSansSC
rm -rf NeoHanSansSC


# fontbakery check-adobefonts "fonts/variable/InterNumeric[wght,RDNS].ttf"

test: build.stamp
fontbakery check-universal "fonts/variable/NeoHanSansSC[wght].ttf" -x com.google.fonts/check/gpos_kerning_info -x com.google.fonts/check/tabular_kerning -x com.google.fonts/check/monospace

test-google: build.stamp
fontbakery check-googlefonts "fonts/variable/NeoHanSansSC[wght].ttf" -x com.google.fonts/check/gpos_kerning_info -x com.google.fonts/check/tabular_kerning -x com.google.fonts/check/monospace

clean:
rm -rf fonts
rm build.stamp

update:
pip install -Ur requirements.txt
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fontmake
gftools
fonttools
fontbakery
shaperglot
chws-tool
17 changes: 17 additions & 0 deletions scripts/get_ver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from glyphsLib import GSFont

"""
Get font version from Glyphspackage source file, store it in verion.txt
No need to keep track of version in a seperate file.
Only used in GitHub Workflows to give artifacts a file name.
"""

def get_font_version(glyphspackage_path):
font = GSFont(glyphspackage_path)

return f"{font.versionMajor}.{font.versionMinor:03}"

inter_numeric_src_path = "src/NeoHanSans-Variable.glyphspackage"

with open("version.txt", "w") as version_file:
version_file.write(get_font_version(inter_numeric_src_path))
31 changes: 31 additions & 0 deletions scripts/stat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from fontTools.ttLib import TTFont
from fontTools.otlLib import builder

"""
Add a STAT table to the Designspace document as a preprocessing before
using fontmake to compile the UFOs to the final binary font.
"""

path = "fonts/variable/NeoHanSansSC[wght].ttf"
font = TTFont(path)

axes = [
dict(
tag="wght",
name="Weight",
values=[
dict(value=100, name='Thin'),
dict(value=200, name='ExtraLight'),
dict(value=300, name='Light'),
dict(value=400, name='Regular', flags=0x2),
dict(value=500, name='Medium'),
dict(value=600, name='SemiBold'),
dict(value=700, name='Bold'),
dict(value=800, name='ExtraBold'),
dict(value=900, name='Black'),
],
)
]

builder.buildStatTable(font, axes)
font.save(path)
5 changes: 0 additions & 5 deletions src/NeoHanSans-Variable.glyphspackage/UIState.plist

This file was deleted.

85 changes: 34 additions & 51 deletions src/NeoHanSans-Variable.glyphspackage/fontinfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ value = (
name = fsType;
value = (
);
},
{
name = panose;
value = (
0,
1,
1,
1,
1,
1,
1,
1,
1,
1
);
}
);
date = "2024-04-15 11:56:13 +0000";
Expand All @@ -29,34 +44,10 @@ axesValues = (
);
customParameters = (
{
name = typoAscender;
value = 880;
},
{
name = typoDescender;
value = -120;
},
{
name = typoLineGap;
value = 0;
},
{
name = winAscent;
value = 1160;
},
{
name = winDescent;
value = 288;
},
{
name = hheaAscender;
value = 1160;
},
{
name = hheaDescender;
value = -288;
},
{
name = strikeoutPosition;
value = 325;
},
Expand All @@ -67,6 +58,14 @@ value = 50;
{
name = underlinePosition;
value = -150;
},
{
name = "CJK Guide";
value = "90";
},
{
name = "CJK Grid";
value = "2";
}
);
iconName = Light;
Expand Down Expand Up @@ -97,34 +96,10 @@ axesValues = (
);
customParameters = (
{
name = typoAscender;
value = 880;
},
{
name = typoDescender;
value = -120;
},
{
name = typoLineGap;
value = 0;
},
{
name = winAscent;
value = 1160;
},
{
name = winDescent;
value = 288;
},
{
name = hheaAscender;
value = 1160;
},
{
name = hheaDescender;
value = -288;
},
{
name = strikeoutPosition;
value = 325;
},
Expand All @@ -135,6 +110,14 @@ value = 50;
{
name = underlinePosition;
value = -150;
},
{
name = "CJK Guide";
value = "90";
},
{
name = "CJK Grid";
value = "2";
}
);
iconName = Bold;
Expand Down Expand Up @@ -199,7 +182,7 @@ weightClass = 500;
axesValues = (
600
);
name = Semibold;
name = SemiBold;
weightClass = 600;
},
{
Expand Down Expand Up @@ -291,6 +274,6 @@ fontType = variable;
previewRemoveOverlap = 0;
};
unitsPerEm = 1000;
versionMajor = 0;
versionMinor = 1;
versionMajor = 1;
versionMinor = 0;
}
16 changes: 16 additions & 0 deletions src/NeoHanSans-Variable.glyphspackage/glyphs/nbspace.glyph
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
color = 8;
glyphname = nbspace;
layers = (
{
layerId = m01;
width = 600;
},
{
layerId = "5029AEDF-C899-4409-998A-C73D58F94579";
width = 200;
}
);
metricWidth = space;
unicode = 160;
}
Loading

0 comments on commit b2cf7f5

Please sign in to comment.