Skip to content

Instantly share code, notes, and snippets.

@zobayer1
Created December 4, 2025 10:45
Show Gist options
  • Select an option

  • Save zobayer1/80d6653200f12bef340d560589bfca45 to your computer and use it in GitHub Desktop.

Select an option

Save zobayer1/80d6653200f12bef340d560589bfca45 to your computer and use it in GitHub Desktop.
Script for downloading Bangla fonts from OmicronLab and install in your system
#!/bin/bash
# Bangla Font Installer Script v1.0
# MIT License
# Downloads and installs Bangla fonts from OmicronLab
set -e # Exit on error
# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print colored messages
print_message() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if required tools are available
check_dependencies() {
local missing_deps=()
if ! command -v wget &> /dev/null && ! command -v curl &> /dev/null; then
missing_deps+=("wget or curl")
fi
if ! command -v fc-cache &> /dev/null; then
missing_deps+=("fontconfig (fc-cache)")
fi
if [ ${#missing_deps[@]} -gt 0 ]; then
print_error "Missing dependencies: ${missing_deps[*]}"
print_message "Please install them first:"
echo " For Debian/Ubuntu: sudo apt install wget fontconfig"
echo " For Fedora/RHEL: sudo dnf install wget fontconfig"
echo " For Arch: sudo pacman -S wget fontconfig"
exit 1
fi
}
# Font URLs (URL-encoded spaces as %20 for consistency)
FONT_URLS=(
"https://www.omicronlab.com/download/fonts/kalpurush.ttf"
"https://www.omicronlab.com/download/fonts/kalpurush%20ANSI.ttf"
"https://www.omicronlab.com/download/fonts/Siyamrupali.ttf"
"https://www.omicronlab.com/download/fonts/Siyam%20Rupali%20ANSI.ttf"
"https://www.omicronlab.com/download/fonts/AponaLohit.ttf"
"https://www.omicronlab.com/download/fonts/SolaimanLipi_20-04-07.ttf"
"https://www.omicronlab.com/download/fonts/Bangla.ttf"
"https://www.omicronlab.com/download/fonts/AdorshoLipi_20-07-2007.ttf"
"https://www.omicronlab.com/download/fonts/BenSen.ttf"
"https://www.omicronlab.com/download/fonts/BenSenHandwriting.ttf"
"https://www.omicronlab.com/download/fonts/Nikosh.ttf"
"https://www.omicronlab.com/download/fonts/NikoshBAN.ttf"
"https://www.omicronlab.com/download/fonts/NikoshGrameen.ttf"
"https://www.omicronlab.com/download/fonts/NikoshLight.ttf"
"https://www.omicronlab.com/download/fonts/NikoshLightBan.ttf"
"https://www.omicronlab.com/download/fonts/akaashnormal.ttf"
"https://www.omicronlab.com/download/fonts/mitra.ttf"
"https://www.omicronlab.com/download/fonts/sagarnormal.ttf"
"https://www.omicronlab.com/download/fonts/muktinarrow.ttf"
"https://www.omicronlab.com/download/fonts/Mukti_1.99_PR.ttf"
"https://www.omicronlab.com/download/fonts/Lohit_14-04-2007.ttf"
)
# Font names for display (without URLs)
FONT_NAMES=(
"kalpurush.ttf"
"kalpurush ANSI.ttf"
"Siyamrupali.ttf"
"Siyam Rupali ANSI.ttf"
"AponaLohit.ttf"
"SolaimanLipi_20-04-07.ttf"
"Bangla.ttf"
"AdorshoLipi_20-07-2007.ttf"
"BenSen.ttf"
"BenSenHandwriting.ttf"
"Nikosh.ttf"
"NikoshBAN.ttf"
"NikoshGrameen.ttf"
"NikoshLight.ttf"
"NikoshLightBan.ttf"
"akaashnormal.ttf"
"mitra.ttf"
"sagarnormal.ttf"
"muktinarrow.ttf"
"Mukti_1.99_PR.ttf"
"Lohit_14-04-2007.ttf"
)
# Choose download tool (prefer wget, fallback to curl)
get_download_tool() {
if command -v wget &> /dev/null; then
echo "wget"
elif command -v curl &> /dev/null; then
echo "curl"
else
echo "none"
fi
}
download_font() {
local url="$1"
local filename="$2"
local download_tool="$3"
# Decode URL-encoded filename for saving
local save_filename=$(echo "$filename" | sed 's/%20/ /g')
print_message "Downloading: $save_filename"
case $download_tool in
"wget")
wget -q --show-progress -O "$FONT_DIR/$save_filename" "$url"
;;
"curl")
curl -L -# -o "$FONT_DIR/$save_filename" "$url"
;;
esac
if [ $? -eq 0 ]; then
print_message "✓ Downloaded: $save_filename"
else
print_warning "Failed to download: $save_filename"
FAILED_DOWNLOADS+=("$save_filename")
fi
}
# Main script
main() {
print_message "Bangla Font Installer"
print_message "======================"
# Check dependencies
check_dependencies
# Choose font directory (user preference)
print_message "Select font installation directory:"
echo " 1) ~/.fonts/bangla (User-specific)"
echo " 2) ~/.local/share/fonts/bangla (User-specific, XDG standard)"
echo " 3) /usr/local/share/fonts/bangla (System-wide - requires sudo)"
read -p "Enter choice [1-3]: " choice
case $choice in
1)
FONT_DIR="$HOME/.fonts/bangla"
SUDO=""
;;
2)
FONT_DIR="$HOME/.local/share/fonts/bangla"
SUDO=""
;;
3)
FONT_DIR="/usr/local/share/fonts/bangla"
SUDO="sudo"
print_warning "System-wide installation requires sudo privileges"
;;
*)
print_message "Invalid choice. Using default: ~/.fonts/bangla"
FONT_DIR="$HOME/.fonts/bangla"
SUDO=""
;;
esac
# Create font directory
print_message "Creating font directory: $FONT_DIR"
$SUDO mkdir -p "$FONT_DIR"
# Get download tool
DOWNLOAD_TOOL=$(get_download_tool)
if [ "$DOWNLOAD_TOOL" = "none" ]; then
print_error "No download tool available (wget or curl)"
exit 1
fi
print_message "Using $DOWNLOAD_TOOL for downloads"
# Download fonts
print_message "Starting download of ${#FONT_URLS[@]} fonts..."
echo ""
FAILED_DOWNLOADS=()
for i in "${!FONT_URLS[@]}"; do
download_font "${FONT_URLS[$i]}" "${FONT_URLS[$i]##*/}" "$DOWNLOAD_TOOL"
done
# Update font cache
print_message ""
print_message "Updating font cache..."
if [ -n "$SUDO" ]; then
$SUDO fc-cache -f -v
else
fc-cache -f -v
fi
# Summary
print_message ""
print_message "================================="
print_message "Installation Complete!"
print_message "================================="
print_message "Fonts installed to: $FONT_DIR"
print_message "Total fonts downloaded: $((${#FONT_URLS[@]} - ${#FAILED_DOWNLOADS[@]}))"
if [ ${#FAILED_DOWNLOADS[@]} -gt 0 ]; then
print_warning "Failed downloads: ${#FAILED_DOWNLOADS[@]}"
for failed in "${FAILED_DOWNLOADS[@]}"; do
echo " - $failed"
done
fi
print_message ""
print_message "To use the fonts, you may need to:"
print_message "1. Restart your applications"
print_message "2. Or log out and log back in"
print_message "3. Check font availability in your applications"
if [ "$choice" = "3" ]; then
print_message ""
print_message "System-wide installation complete. All users can now use these fonts."
fi
}
# Run main function
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment