#!/bin/bash

FONTS_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

sourceCodePro="https://github.com/adobe-fonts/source-code-pro"
awsomeFont="https://use.fontawesome.com/releases/v6.2.1/fontawesome-free-6.2.1-desktop.zip"

intro()
{
	graphics_install_prompt "Following Fonts Will be installed"
	graphics_install_prompt "$sourceCodePro"
	graphics_install_prompt "$awsomeFont"
	
	if [[ -d "$FONTS_DIR" ]]
	then
		graphics_comment "$FONTS_DIR Exists"
	else 
		graphics_comment "$FONTS_DIR Will be created"
		sudo mkdir $FONTS_DIR
	fi
}

outro()
{
	graphics_install_prompt "fonts installation complete"
	cd $MAIN_DIR
}

install_fonts()
{
	intro
	
	cd $FONTS_SCRIPT_DIR
	
	git clone $sourceCodePro
	
	if [[ -d "$FONTS_DIR/source-code-pro" ]]
	then
		graphics_comment "A version of source-code-pro exits and will be repacled"
		sudo rm -r $FONTS_DIR/source-code-pro
	else
		graphics_comment "Creating $FONTS_DIR/source-code-pro directory" 
	fi
	
	sudo cp -r source-code-pro $FONTS_DIR
	sudo chmod -R 555 $FONTS_DIR/source-code-pro
	sudo rm -r source-code-pro

	wget $awsomeFont 
	unzip *.zip
	rm *.zip

	dir=$(find . -mindepth 1 -maxdepth 1 -type d)

	if [[ -d "$FONTS_DIR/fontawesome" ]]
	then
		graphics_comment "A version of awsomeFont exits and will be repacled"
		sudo rm -r $FONTS_DIR/fontawesome
	else
		graphics_comment "Creating $FONTS_DIR/fontawesome directory" 
	fi

	sudo cp -r $dir $FONTS_DIR/fontawesome
	sudo chmod -R 555 $FONTS_DIR/fontawesome
	rm -r $dir
	fc-cache -v
	outro
}
