#!/usr/bin/env zsh # prepare fonts custom_fonts=() total_fonts=0 # ${#fonts} # if there are custom fonts add them [[ -r fonts ]] && { notice "Indexing custom fonts" rm -f ${destination}/css/custom.fonts.css mkdir -p ${destination}/css ttf=`find -L fonts -iname '*.ttf'` for f in ${(f)ttf}; do ffile=`basename "$f"` cp "$f" ${destination}/css/"$ffile" custom_fonts+=("${ffile%.ttf}") cat <> ${destination}/css/custom.fonts.css @font-face { font-family: '${ffile%.ttf}'; src: url('$ffile') format('truetype'); } EOF total_fonts=$(( $total_fonts + 1 )) done otf=`find -L fonts -iname '*.otf'` for f in ${(f)otf}; do ffile=`basename "$f"` cp "$f" ${destination}/css/"$ffile" custom_fonts+=("${ffile%.otf}") cat <> ${destination}/css/custom.fonts.css @font-face { font-family: '${ffile%.otf}'; src: url('$ffile') format('opentype'); } EOF total_fonts=$(( $total_fonts + 1 )) done woff=`find -L fonts -iname '*.woff'` for f in ${(f)woff}; do ffile=`basename "$f"` cp "$f" ${destination}/css/"$ffile" custom_fonts+=("${ffile%.woff}") cat <> ${destination}/css/custom.fonts.css @font-face { font-family: '${ffile%.woff}'; src: url('$ffile') format('woff'); } EOF total_fonts=$(( $total_fonts + 1 )) done act "$total_fonts custom fonts indexed" } fonts=($custom_fonts $fonts)