Created
August 24, 2023 16:45
-
-
Save ryanccn/01cfe2f248dd858eb7e12ad77ae646a4 to your computer and use it in GitHub Desktop.
Patch IBM Plex font families to use standard Medium and SemiBold naming instead of Medm and SmBld to improve compatibility
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
#! /usr/bin/env nix-shell | |
#! nix-shell --pure --keep DEBUG -i bash -p bash coreutils fd python311Packages.fonttools | |
# shellcheck shell=bash | |
set -eo pipefail | |
ansi_dim="\033[2m" | |
ansi_blue="\033[34m" | |
ansi_green="\033[32m" | |
ansi_reset="\033[0m" | |
run() { | |
echo -e "${ansi_dim}$ $*${ansi_reset}" | |
if [ -z "$DEBUG" ]; then | |
"$@" &> /dev/null | |
else | |
"$@" | |
fi | |
} | |
medium_fonts=$(fd --extension=otf Medium) | |
for medium_font in $medium_fonts; do | |
echo -e "${ansi_blue}Patching${ansi_reset} $medium_font (Medm -> Medium)" | |
ttx_path="${medium_font%.*}.ttx" | |
run ttx "$medium_font" | |
run sed -i 's/Medm/Medium/g' "$ttx_path" | |
run ttx -f "$ttx_path" | |
done | |
semibold_fonts=$(fd --extension=otf SemiBold) | |
for semibold_font in $semibold_fonts; do | |
echo -e "${ansi_blue}Patching${ansi_reset} $semibold_font (SmBld -> Semibold)" | |
ttx_path="${semibold_font%.*}.ttx" | |
run ttx "$semibold_font" | |
run sed -i 's/SmBld/Semibold/g' "$ttx_path" | |
run ttx -f "$ttx_path" | |
done | |
echo -e "${ansi_green}Done!${ansi_reset}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment