Created
November 3, 2024 11:47
-
-
Save azdanov/73f240929f7cc71366a522915340a341 to your computer and use it in GitHub Desktop.
Shell script to install apple fonts on Linux
This file contains hidden or 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
#!/bin/bash | |
# Script to download and install Apple fonts on Ubuntu | |
# Inspired by the PKGBUILD script for Arch Linux | |
# Install wget p7zip-full fontconfig before running the script | |
set -e | |
# Create temporary directories | |
TEMP_DIR=$(mktemp -d) | |
FONTS_DIR="$TEMP_DIR/fonts" | |
SRC_DIR="$TEMP_DIR/src" | |
mkdir -p "$FONTS_DIR" "$SRC_DIR" | |
# Download font packages | |
echo "Downloading font packages..." | |
wget -q -O "$TEMP_DIR/SF-Pro.dmg" "https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg" | |
wget -q -O "$TEMP_DIR/SF-Compact.dmg" "https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg" | |
wget -q -O "$TEMP_DIR/SF-Mono.dmg" "https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg" | |
wget -q -O "$TEMP_DIR/NY.dmg" "https://devimages-cdn.apple.com/design/resources/download/NY.dmg" | |
# Extract fonts | |
echo "Extracting fonts..." | |
for dmg in "$TEMP_DIR"/*.dmg; do | |
7z e "$dmg" -y -o"$SRC_DIR" > /dev/null | |
cd "$SRC_DIR" | |
7z x *.pkg -y > /dev/null | |
7z x 'Payload~' -y > /dev/null | |
mv Library/Fonts/* "$FONTS_DIR/" | |
rm -rf ./* | |
cd "$TEMP_DIR" | |
done | |
# Install fonts | |
echo "Installing fonts..." | |
sudo mkdir -p /usr/local/share/fonts/apple-fonts | |
sudo cp "$FONTS_DIR"/* /usr/local/share/fonts/apple-fonts/ | |
# Update font cache | |
echo "Updating font cache..." | |
sudo fc-cache -f -v | |
# Clean up | |
echo "Cleaning up..." | |
rm -rf "$TEMP_DIR" | |
echo "Apple fonts have been installed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment