-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_CNS11643_fonts_ubuntu.sh
executable file
·80 lines (67 loc) · 2.11 KB
/
install_CNS11643_fonts_ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# ######################################################################################################## #
# Author: hms5232
# Source code and manual on https://github.com/hms5232/ubuntu-install-CNS11643-fonts
# Contact, report bugs or ask questions: https://github.com/hms5232/ubuntu-install-CNS11643-fonts/issues
# ######################################################################################################## #
need_download=true
# if ~/.fonts dir not exist, then create it.
if [ ! -d "$HOME/.fonts" ] ; then
mkdir $HOME/.fonts
echo -e "create ~/.fonts/ \n"
fi
# when Open_Data.zip exists, users must check out they wanna to download again or not
if [ -f "Open_Data.zip" ] ; then
read -p "Open_Data.zip already exists. Do you want to delete it and download again? [y/n]" re_download
case $re_download in
[yY][eE][sS]|[yY])
echo -e "remove Open_Data.zip...\n"
rm Open_Data.zip
echo -e "\n"
;;
*)
read -p "Use the existing Open_Data.zip? [y/n]" re_use
case $re_use in
[yY][eE][sS]|[yY])
need_download=false
echo -e "Skip download."
echo -e "\n"
;;
*)
echo -e "\n"
echo -e "============== Exit shell script! =============="
exit
;;
esac
esac
fi
# Let's download font
if $need_download ; then
# download CNS11643中文標準交換碼全字庫(簡稱全字庫)
# 正楷體、正宋體
# TW-Kai, TW-Sung
wget http://www.cns11643.gov.tw/AIDB/Open_Data.zip
fi
# let's hash it~
# but we don't have offical sha1sum file Orz
hash=$(sha1sum Open_Data.zip | cut -d ' ' -f 1)
echo -e "\n The SHA1 value of downloaded file is \n"
echo -e "\t>>>>> $hash <<<<<\n"
# unzip
unzip Open_Data.zip
# check zip file download and upzip succefully
if [ ! -d "Open_Data/" ] ; then
echo -e "\n\n"
echo -e "\a========= The font file went wrong! Please try again later. =========\n"
exit 1
fi
# copy fonts to ~/.fonts
cp -i Open_Data/Fonts/*.ttf $HOME/.fonts
# refresh fonts cache
sudo fc-cache -fv
# remove zip and unzip dir
rm Open_Data.zip
rm -r Open_Data/
# finally
echo -e "\n\n"
echo -e "============== This is the end of script. ============== \n"