From 5cb0b73d992f21d3ec62acb5bfa5440eb913c2ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20Gro=C3=9F?= Date: Mon, 15 Apr 2019 10:49:33 +0200 Subject: [PATCH 1/8] Replaced etree dependecy with lxml to avoid UnicodeDecodeError --- README.md | 1 + scfbuild/builder.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab90074..33e5489 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Required Python libraries: * FontTools 2.5+ * FontForge +* lxml Run: `bin/scfbuild` diff --git a/scfbuild/builder.py b/scfbuild/builder.py index 8d6275a..a27037f 100644 --- a/scfbuild/builder.py +++ b/scfbuild/builder.py @@ -12,7 +12,7 @@ import tempfile import time from distutils.version import LooseVersion -import xml.etree.ElementTree as ET +from lxml import etree as ET import fontTools from fontTools.ttLib import TTFont @@ -89,7 +89,7 @@ def add_color_svg(self): svg_list = [] # Set default namespace (avoids "ns0:svg") - ET.register_namespace("", "http://www.w3.org/2000/svg") + ET.register_namespace("svg", "http://www.w3.org/2000/svg") for filepath in svg_files: glyph_id = self.get_glyph_id(filepath) From 132fdbd9bb75e258cafb321d335098510c39ed0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20Gro=C3=9F?= Date: Tue, 11 Feb 2020 11:49:58 +0100 Subject: [PATCH 2/8] Added Dockerfile and instructions --- Dockerfile | 8 ++++++++ README.md | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4df4216 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install python-pip -y +RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org fonttools +RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org pyyaml +RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org lxml +RUN apt-get install fontforge python-fontforge -y diff --git a/README.md b/README.md index 33e5489..10865d7 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,23 @@ optional arguments: -V, --version print version information ``` +## Docker + +If you don't want to install the required Python libraries from above locally on your machine, then you can use the provided Docker container, which bundles nicely all requirements. + +1. Install [Docker](https://www.docker.com/) + +2. Build Docker container: `docker build -t scfbuild .` +3. Run and share folder with container: + +```bash +$ cd path/to/repo/scfbuild +$ docker run --interactive --tty --rm --volume $PWD:/wd --workdir /wd scfbuild:latest bash +# now you can use bin/scfbuild via the docker container +$ bin/scfbuild --help +``` + + ## Other Tools `scfbuild` softens the learning curve for font creation, but cannot replace more From a7dbb24bdb00e8e4c2a8872785aa4636428d32c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20Gro=C3=9F?= Date: Tue, 11 Feb 2020 16:28:56 +0100 Subject: [PATCH 3/8] Copy scfbuild repo folder to docker container --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4df4216..c119c9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,3 +6,5 @@ RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org fo RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org pyyaml RUN pip install --trusted-host=pypi.org --trusted-host=files.pythonhosted.org lxml RUN apt-get install fontforge python-fontforge -y + +COPY . /scfbuild From 47e6474fc2535c7b1828841c54ae80038805e047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20Gro=C3=9F?= Date: Wed, 12 Feb 2020 10:06:19 +0100 Subject: [PATCH 4/8] Added --glyph-only (generate font with no-color SVG glyphs only) --- README.md | 1 + scfbuild/builder.py | 9 +++++++-- scfbuild/main.py | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10865d7..11970ef 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ optional arguments: -s DIR, --color-svg-dir DIR directory of SVGinOT color SVG glyphs to add to the font. + --glyph-only generate font with no-color SVG glyphs only --transform TRANSFORM add a transform to the tag of each color SVG. Example "translate(0 -1638) scale(2.048)" diff --git a/scfbuild/builder.py b/scfbuild/builder.py index a27037f..c3257f9 100644 --- a/scfbuild/builder.py +++ b/scfbuild/builder.py @@ -69,9 +69,14 @@ def run(self): logger.info("Reading intermediate font file") self.font = TTFont(tmp_file) - logger.info("Adding SVGinOT SVG files") # TODO: Validate color SVGs - self.add_color_svg() + + if self.conf['glyph_only'] == False: + logger.info("Adding SVGinOT SVG files") + self.add_color_svg() + else: + logger.info("Not Adding SVGinOT SVG files") + self.add_name_table() logger.info("Saving output file: %s", self.conf['output_file']) self.font.save(self.conf['output_file']) diff --git a/scfbuild/main.py b/scfbuild/main.py index 3c160dc..e21e050 100644 --- a/scfbuild/main.py +++ b/scfbuild/main.py @@ -28,6 +28,10 @@ def main(): dest='glyph_svg_dir', metavar='DIR', help='directory of regular no-color SVG glyphs to add to the font') + parser.add_argument('--glyph-only', + dest='glyph_only', + action='store_true', + help='generate font with no-color SVG glyphs only') parser.add_argument('-s', '--color-svg-dir', dest='color_svg_dir', metavar='DIR', @@ -89,6 +93,8 @@ def main(): conf['table_name'] = {} if 'verbose' not in conf: conf['verbose'] = False + if 'glyph_only' not in conf: + conf['glyph_only'] = False # Command line options override YAML if args.output: @@ -101,6 +107,8 @@ def main(): conf['color_svg_transform'] = args.transform if args.verbose: conf['verbose'] = True + if args.glyph_only: + conf['glyph_only'] = args.glyph_only # Be sure family name, subfamily, and version are set to something. if 'family' not in conf['table_name'] or args.family is not default_family: From 41db848747b44b23ced5cdb87750d20e90602089 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Fri, 22 May 2020 19:20:29 +0100 Subject: [PATCH 5/8] Add some less commonly used name IDs. --- scfbuild/builder.py | 6 +++++- scfbuild/constants/name_record.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scfbuild/builder.py b/scfbuild/builder.py index 8d6275a..e4833c3 100644 --- a/scfbuild/builder.py +++ b/scfbuild/builder.py @@ -258,7 +258,11 @@ def add_name_table(self): ('url_vendor', NR.URL_VENDOR), ('url_designer', NR.URL_DESIGNER), ('license', NR.LICENSE), - ('url_license', NR.URL_LICENSE)): + ('url_license', NR.URL_LICENSE), + ('typographic_family', NR.TYPOGRAPHIC_FAMILY), + ('typographic_subfamily', NR.TYPOGRAPHIC_SUBFAMILY), + ('wws_family', NR.WWS_FAMILY), + ('wws_subfamily', NR.WWS_SUBFAMILY)): if key in tn: self.add_name_records(tn[key], name_id) diff --git a/scfbuild/constants/name_record.py b/scfbuild/constants/name_record.py index afd7854..ac3b312 100644 --- a/scfbuild/constants/name_record.py +++ b/scfbuild/constants/name_record.py @@ -51,3 +51,7 @@ URL_DESIGNER = 12 LICENSE = 13 URL_LICENSE = 14 +TYPOGRAPHIC_FAMILY = 16 +TYPOGRAPHIC_SUBFAMILY = 17 +WWS_FAMILY = 21 +WWS_SUBFAMILY = 22 From 164e57569c57fa0b97762671da6ae61aef4dfb33 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Thu, 1 Apr 2021 13:14:58 +0100 Subject: [PATCH 6/8] Have GitHub build the container for us. To make this work: - Generate a secret token at https://github.com/settings/tokens/new?scopes=write:packages,delete:packages - Paste the token into https://github.com//scfbuild/settings/secrets/actions/new with name CR_PAT --- .github/workflows/docker-publish.yml | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..79a3a2b --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,76 @@ +name: Docker + +on: + push: + # Publish `master` as Docker `latest` image. + branches: + - master + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + +env: + # TODO: Change variable to your image's name. + IMAGE_NAME: bga_discord + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + if [ -f docker-compose.test.yml ]; then + docker-compose --file docker-compose.test.yml build + docker-compose --file docker-compose.test.yml run sut + else + docker build . --file Dockerfile + fi + + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + # Ensure test job passes before pushing image. + needs: test + + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build . --file Dockerfile --tag $IMAGE_NAME + + - name: Log into registry + run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME + + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION From c1684643cbdde95e17335a969e6db5b09a95f5e3 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Thu, 1 Apr 2021 17:07:03 +0100 Subject: [PATCH 7/8] Fix copy/paste error. --- .github/workflows/docker-publish.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 79a3a2b..93efa13 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -14,8 +14,7 @@ on: pull_request: env: - # TODO: Change variable to your image's name. - IMAGE_NAME: bga_discord + IMAGE_NAME: scfbuild jobs: # Run tests. From 6ce8ce07f1c0ad497eaf7596db87fb06f811590e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20Gro=C3=9F?= Date: Tue, 6 Apr 2021 14:54:20 +0200 Subject: [PATCH 8/8] Added hint for docker pull ghcr.io/b-g/scfbuild --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11970ef..63bfcd0 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ If you don't want to install the required Python libraries from above locally on 1. Install [Docker](https://www.docker.com/) -2. Build Docker container: `docker build -t scfbuild .` +2. Either A) build the container on your onw: `docker build -t scfbuild .` or B) pull the latest published container: `docker pull ghcr.io/b-g/scfbuild/scfbuild:latest` 3. Run and share folder with container: ```bash