-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcopyResources.sh
executable file
·116 lines (103 loc) · 3.74 KB
/
copyResources.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
set -e
if [ "$EUID" -ne 0 ]
then
echo "This script must be run as root"
exit 1
fi
if [[ -z $1 ]]
then
echo "Runtime version required"
exit 1
fi
FOLDER=EmojiFont
if [[ -z $2 ]]
then
echo "Font must be specified"
exit 1
fi
if [[ ! -f "${FOLDER}/${2}" ]]
then
echo "Font not found"
exit 1
fi
FONT="${2}"
UNDERSCORE=0
IS_14=0
EL_RUNTIME_ROOT=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS\ ${1}.simruntime/Contents/Resources/RuntimeRoot
if (( $(echo "$1 >= 8.2" | bc -l) ))
then
if (( $(echo "$1 >= 14.0" | bc -l) ))
then
LOCATION="CoreAddition"
IS_14=1
else
LOCATION="Core"
fi
if (( $(echo "$1 == 8.2" | bc -l) ))
then
UNDERSCORE=1
fi
else
LOCATION="Cache"
fi
TOUCH="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/installed"
TTF_2X="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/[email protected]"
TTF_2X_="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji_2x.ttf"
CCF_2X="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/[email protected]"
TTC_160="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji-160px.ttc"
TTC_2X="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/[email protected]"
TTF="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji.ttf"
TTF_="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji_1x.ttf"
CCF="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji.ccf"
TTC="${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/AppleColorEmoji.ttc"
function install {
[[ -f "${TTC_2X}" ]] && mv -v "${TTC_2X}" "${TTC_2X/.ttc/.ttc.bak}"
[[ -f "${TTF_2X}" ]] && mv -v "${TTF_2X}" "${TTF_2X/.ttf/.ttf.bak}"
[[ -f "${CCF_2X}" ]] && mv -v "${CCF_2X}" "${CCF_2X/.ccf/.ccf.bak}"
[[ -f "${TTF_2X_}" ]] && mv -v "${TTF_2X_}" "${TTF_2X_/.ttf/.ttf.bak}"
[[ -f "${TTC_160}" ]] && mv -v "${TTC_160}" "${TTC_160/.ttc/.ttc.bak}"
[[ -f "${TTC}" ]] && mv -v "${TTC}" "${TTC/.ttc/.ttc.bak}"
[[ -f "${TTF}" ]] && mv -v "${TTF}" "${TTF/.ttf/.ttf.bak}"
[[ -f "${TTF_}" ]] && mv -v "${TTF_}" "${TTF_/.ttf/.ttf.bak}"
[[ -f "${CCF}" ]] && mv -v "${CCF}" "${CCF/.ccf/.ccf.bak}"
TARGET_FONT_NAME=${FONT}
if (( $(echo "$UNDERSCORE == 1" | bc -l) ))
then
TARGET_FONT_NAME="${TARGET_FONT_NAME/@/_}"
cp -v "${PWD}/${FOLDER}/${FONT}" "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${TARGET_FONT_NAME}"
cp -v "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${TARGET_FONT_NAME}" "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${TARGET_FONT_NAME/2x/1x}"
else
if [ $IS_14 ]
then
TARGET_FONT_NAME="AppleColorEmoji-160px.ttc"
fi
cp -v "${PWD}/${FOLDER}/${FONT}" "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${TARGET_FONT_NAME}"
if [ $IS_14 -ne 1 ]
then
cp -v "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${FONT}" "${EL_RUNTIME_ROOT}/System/Library/Fonts/${LOCATION}/${TARGET_FONT_NAME/@2x/}"
fi
fi
touch "${TOUCH}"
}
if [[ ! -f "${TOUCH}" ]]
then
install
else
if [ $IS_14 ]
then
[[ -f "${TTC_160/.ttc/.ttc.bak}" ]] && mv -v "${TTC_160/.ttc/.ttc.bak}" "${TTC_160}"
else
[[ -f "${TTC_2X/.ttc/.ttc.bak}" ]] && mv -v "${TTC_2X/.ttc/.ttc.bak}" "${TTC_2X}"
[[ -f "${TTF_2X/.ttf/.ttf.bak}" ]] && mv -v "${TTF_2X/.ttf/.ttf.bak}" "${TTF_2X}"
[[ -f "${CCF_2X/.ccf/.ccf.bak}" ]] && mv -v "${CCF_2X/.ccf/.ccf.bak}" "${CCF_2X}"
[[ -f "${TTF_2X_/.ttf/.ttf.bak}" ]] && mv -v "${TTF_2X_/.ttf/.ttf.bak}" "${TTF_2X_}"
[[ -f "${TTC/.ttc/.ttc.bak}" ]] && mv -v "${TTC/.ttc/.ttc.bak}" "${TTC}"
[[ -f "${TTF/.ttf/.ttf.bak}" ]] && mv -v "${TTF/.ttf/.ttf.bak}" "${TTF}"
[[ -f "${TTF_/.ttf/.ttf.bak}" ]] && mv -v "${TTF_/.ttf/.ttf.bak}" "${TTF_}"
[[ -f "${CCF/.ccf/.ccf.bak}" ]] && mv -v "${CCF/.ccf/.ccf.bak}" "${CCF}"
fi
rm -f "${TOUCH}"
install
fi
# sudo ./copyResource.sh <version> [email protected]