From 375c0c2d133ded0d40bb27c30b9a5b305c59f37e Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 18 Aug 2022 14:47:34 +0200 Subject: [PATCH 1/6] CI: Use fontforge March 2022 to create patched fonts [why] Fontforge 2020 March or 20th Anniversary have problems to generate fonts with a lot of table entries. This is for example the massive entries for ligatures in Iosevka. We can not generate valid font files with that fontforge versions. We can not even detect (from Python side) if fontforge had problems. [how] We fixed fontforge itself upstream with https://github.com/fontforge/fontforge/pull/4883 That fix became available first with Fontforge March 2022 Release. We could use the AppImage or build from scratch, because no package is available on Ubuntu 20.04 or 22.04. Signed-off-by: Fini Jastrow --- .github/workflows/release.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2506cae67..f71b00d013 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,10 +83,23 @@ jobs: run: | sudo apt update -y -q sudo apt install software-properties-common -y -q - sudo apt update -y -q - sudo apt install fontforge -y -q sudo apt install python3-fontforge -y -q + # Ubuntu 20.04 has only fontforge release 2020, but there are some vital bugfixes in the 2022 release + # This can be replaced with the ordinary apt package when Ubuntu updates, probably with 22.10? + - name: Install FontForge (self built) + run: | + sudo apt install libjpeg-dev libtiff5-dev libpng-dev libfreetype6-dev libgif-dev libgtk-3-dev libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev python3-dev ninja-build cmake build-essential gettext libuninameslist-dev -y -q + curl -Lv "https://github.com/fontforge/fontforge/releases/download/20220308/fontforge-20220308.tar.xz" \ + --output FontForge.tar.xz + tar -xf FontForge.tar.xz + cd fontforge-* + sudo mkdir build + cd build + sudo cmake -GNinja .. + sudo ninja + sudo ninja install + - name: Setup additional dependencies run: | pip install fonttools --quiet From 0b307cdde9fe7a767093f41ca9b234141b058127 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 18 Aug 2022 16:35:46 +0200 Subject: [PATCH 2/6] CI: Update action/checkout to v3 [why] * Automatically does a shallow checkout, what we want anyhow * Keep up to date Signed-off-by: Fini Jastrow --- .github/workflows/docker-release.yml | 2 +- .github/workflows/font-patcher.yml | 2 +- .github/workflows/release.yml | 17 ++++------------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index fd0ba2d2bb..26bc485129 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -16,7 +16,7 @@ jobs: name: Publish image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Build image run: docker build -t nerdfonts/patcher . - name: Push image diff --git a/.github/workflows/font-patcher.yml b/.github/workflows/font-patcher.yml index fdfdff91b5..e1ef657c6c 100644 --- a/.github/workflows/font-patcher.yml +++ b/.github/workflows/font-patcher.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Setup core dependencies run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f71b00d013..1d3caedbe9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,10 +27,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - ref: master - fetch-depth: '1' + - uses: actions/checkout@v3 - id: set-matrix run: | @@ -60,11 +57,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - with: - ref: master - fetch-depth: '1' - + - uses: actions/checkout@v3 - name: Set release variables run: | cd -- "$GITHUB_WORKSPACE" @@ -177,8 +170,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 - name: Set release variables run: | cd -- "$GITHUB_WORKSPACE" @@ -206,8 +198,7 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v3 - name: Download patched fonts from build id: download-patched-fonts uses: actions/download-artifact@v2 From fc2c7cacccf56cb9f80781c3cffd2dd7ef05c6c9 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 18 Aug 2022 17:22:56 +0200 Subject: [PATCH 3/6] CI: Cache self-built fontforge for all steps Signed-off-by: Fini Jastrow --- .github/workflows/release.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d3caedbe9..a7f14b1058 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,20 +77,32 @@ jobs: sudo apt update -y -q sudo apt install software-properties-common -y -q sudo apt install python3-fontforge -y -q + sudo apt install libjpeg-dev libtiff5-dev libpng-dev libfreetype6-dev libgif-dev libgtk-3-dev libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev python3-dev ninja-build cmake build-essential gettext libuninameslist-dev -y -q # Ubuntu 20.04 has only fontforge release 2020, but there are some vital bugfixes in the 2022 release # This can be replaced with the ordinary apt package when Ubuntu updates, probably with 22.10? - - name: Install FontForge (self built) + - name: Cache Fontforge executable + id: cache-fontforge + uses: actions/cache@v3 + with: + path: fontforge-20220308 + key: ${{ runner.os }}-fontforge + + - name: Build FontForge + if: steps.cache-fontforge.outputs.cache-hit != 'true' run: | - sudo apt install libjpeg-dev libtiff5-dev libpng-dev libfreetype6-dev libgif-dev libgtk-3-dev libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev python3-dev ninja-build cmake build-essential gettext libuninameslist-dev -y -q curl -Lv "https://github.com/fontforge/fontforge/releases/download/20220308/fontforge-20220308.tar.xz" \ --output FontForge.tar.xz tar -xf FontForge.tar.xz - cd fontforge-* + cd fontforge-20220308 sudo mkdir build cd build sudo cmake -GNinja .. sudo ninja + + - name: Install Fontforge + run: | + cd fontforge-20220308/build sudo ninja install - name: Setup additional dependencies From a4315e8de1fc9ca8c2993269c34772fc7a7a5d04 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Thu, 18 Aug 2022 18:25:59 +0200 Subject: [PATCH 4/6] CI: Fix patch-em-all: Purge destination dirs if possible [why] The purged (obsolete) files are still existing after release. [how] We restore the deleted files before it adds the new ones. Just delete all font files and then download all the release files (all newly created fonts). `git add` on a directory will remove all missing files. Signed-off-by: Fini Jastrow --- .github/workflows/release.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7f14b1058..04ad1b4eca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -211,6 +211,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Prepare repo (clear out old and obsolete fonts) + run: | + cd -- "$GITHUB_WORKSPACE/patched-fonts" + find . -name "*.[to]tf" -exec rm {} \; + - name: Download patched fonts from build id: download-patched-fonts uses: actions/download-artifact@v2 @@ -218,9 +223,9 @@ jobs: name: patched-fonts path: . - - uses: EndBug/add-and-commit@v7 + - uses: EndBug/add-and-commit@v9 with: add: 'patched-fonts' message: Rebuilds patched fonts committer_name: GitHub Actions - committer_email: 41898282+github-actions[bot]@users.noreply.github.com \ No newline at end of file + committer_email: 41898282+github-actions[bot]@users.noreply.github.com From f08e6a6c9ac5e864a70f03ab7c9e28e5c20f1ff0 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Fri, 19 Aug 2022 12:57:42 +0200 Subject: [PATCH 5/6] CI: Use fontforge March 2022 AppImage [why] It might be easier to use the precompiled application than to build it ourselves. [how] The AppImage has the typical problem with relative paths, so we need to change some small calls. Signed-off-by: Fini Jastrow --- .github/workflows/release.yml | 37 ++++++------------- .../gotta-patch-em-all-font-patcher!.sh | 11 +++--- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04ad1b4eca..65dbea66e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,33 +77,20 @@ jobs: sudo apt update -y -q sudo apt install software-properties-common -y -q sudo apt install python3-fontforge -y -q - sudo apt install libjpeg-dev libtiff5-dev libpng-dev libfreetype6-dev libgif-dev libgtk-3-dev libxml2-dev libpango1.0-dev libcairo2-dev libspiro-dev python3-dev ninja-build cmake build-essential gettext libuninameslist-dev -y -q # Ubuntu 20.04 has only fontforge release 2020, but there are some vital bugfixes in the 2022 release # This can be replaced with the ordinary apt package when Ubuntu updates, probably with 22.10? - - name: Cache Fontforge executable - id: cache-fontforge - uses: actions/cache@v3 - with: - path: fontforge-20220308 - key: ${{ runner.os }}-fontforge - - - name: Build FontForge - if: steps.cache-fontforge.outputs.cache-hit != 'true' - run: | - curl -Lv "https://github.com/fontforge/fontforge/releases/download/20220308/fontforge-20220308.tar.xz" \ - --output FontForge.tar.xz - tar -xf FontForge.tar.xz - cd fontforge-20220308 - sudo mkdir build - cd build - sudo cmake -GNinja .. - sudo ninja - - - name: Install Fontforge - run: | - cd fontforge-20220308/build - sudo ninja install + - name: Fetch FontForge + run: | + curl -L "https://github.com/fontforge/fontforge/releases/download/20220308/FontForge-2022-03-08-582bd41-x86_64.AppImage" \ + --output fontforge + chmod u+x fontforge + echo Try appimage + ./fontforge --version + export PATH=`pwd`:$PATH + echo "PATH=$PATH" >> $GITHUB_ENV + echo Try appimage with path + fontforge --version - name: Setup additional dependencies run: | @@ -147,7 +134,7 @@ jobs: - name: Patch all the variations of the font family run: | cd -- "$GITHUB_WORKSPACE/bin/scripts" - fontforge --script ../../font-patcher --version + fontforge --script `pwd`/../../font-patcher --version ./gotta-patch-em-all-font-patcher\!.sh "/${{ matrix.font }}" - name: Generate fontconfig and casks diff --git a/bin/scripts/gotta-patch-em-all-font-patcher!.sh b/bin/scripts/gotta-patch-em-all-font-patcher!.sh index 8aea4bfcfa..0e00828119 100755 --- a/bin/scripts/gotta-patch-em-all-font-patcher!.sh +++ b/bin/scripts/gotta-patch-em-all-font-patcher!.sh @@ -141,11 +141,12 @@ function patch_font { echo >&2 "# Could not find project parent directory" exit 1 } - - fontforge -quiet -script ./font-patcher "$f" -q $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null - fontforge -quiet -script ./font-patcher "$f" -q -s ${font_config} $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null - fontforge -quiet -script ./font-patcher "$f" -q -w $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null - fontforge -quiet -script ./font-patcher "$f" -q -s ${font_config} -w $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + # Use absolute path to allow fontforge being an AppImage (used in CI) + PWD=`pwd` + fontforge -quiet -script $PWD/font-patcher "$f" -q $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script $PWD/font-patcher "$f" -q -s ${font_config} $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script $PWD/font-patcher "$f" -q -w $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script $PWD/font-patcher "$f" -q -s ${font_config} -w $powerline $post_process --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null # wait for this group of background processes to finish to avoid forking too many processes # that can add up quickly with the number of combinations #wait From 900e34ebb3d933f6e7f59a6c76a501e90e8ec9dd Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Fri, 19 Aug 2022 13:07:28 +0200 Subject: [PATCH 6/6] gotta-patch-em-all: Fix filename parsing (part 2) [why] The new 'pathname' pattern always added a '*' glob to the end. So when we wanted to (just) recreate "Inconsolata" (by specifying "/Inconsolata") that means "/Inconsolata*/*.[to]tf". But that includes also "IncolsolataGo" and "InconsolataLCG" :-( [how] Just remove the globbing after the pathname. If a pathname is specified it must be the correct pathname and no star is added per default. Users could still specify "/Incon*" to get all Inconsolatas in the pathname based filter mode. --- bin/scripts/gotta-patch-em-all-font-patcher!.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/scripts/gotta-patch-em-all-font-patcher!.sh b/bin/scripts/gotta-patch-em-all-font-patcher!.sh index 0e00828119..56ba97d2a7 100755 --- a/bin/scripts/gotta-patch-em-all-font-patcher!.sh +++ b/bin/scripts/gotta-patch-em-all-font-patcher!.sh @@ -13,7 +13,7 @@ # If the argument starts with a '/' all font files in a directory that matches # the filter are processed only. # Example ./gotta-patch-em-all-font-patcher\!.sh "/iosevka" -# Process all font files that are in directories that start with "iosevka" +# Process all font files that are in directory "iosevka" # for executing script to rebuild JUST the readmes: # ./gotta-patch-em-all-font-patcher\!.sh "" info @@ -55,7 +55,7 @@ then if [[ "${1:0:1}" == "/" ]] then like_mode="-ipath" - like_pattern="*$1*/*.[o,t]tf" + like_pattern="*$1/*.[o,t]tf" echo "$LINE_PREFIX Parameter given, limiting search and patch to pathname pattern '$1' given" else like_mode="-iname"