This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
post-fs-data.sh
126 lines (106 loc) · 6.98 KB
/
post-fs-data.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
117
118
119
120
121
122
123
124
125
126
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in post-fs-data mode
APILEVEL=$(getprop ro.build.version.sdk)
#Copy original fonts.xml to the MODDIR to overwrite dummy file
mkdir $MODDIR/system/etc
cp /system/etc/fonts.xml $MODDIR/system/etc
#Function to remove original ja
remove_ja() {
sed -i -e '/<family lang="ja"/,/<\/family>/d' $1
}
#Function to add ja above zh-Hans
add_ja() {
if [ $APILEVEL -ge 31 ] ; then
#Android 12 and later
sed -i 's@<family lang="zh-Hans">@<family lang="ja">\n <font weight="100" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Thin.ttf</font>\n <font weight="300" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Light.ttf</font>\n <font weight="400" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Regular.ttf</font>\n <font weight="600" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Semibold.ttf</font>\n <font weight="700" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Bold.ttf</font>\n <font weight="800" style="normal" postScriptName="NotoSansCJKjp-Regular">Koruri-Extrabold.ttf</font>\n <font weight="100" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Thin.ttf</font>\n <font weight="300" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Light.ttf</font>\n <font weight="400" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Regular.ttf</font>\n <font weight="600" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Semibold.ttf</font>\n <font weight="700" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Bold.ttf</font>\n <font weight="800" style="normal" postScriptName="NotoSansCJKjp-Regular" fallbackFor="serif">Koruri-Extrabold.ttf</font>\n </family>\n <family lang="zh-Hans">@g' $1
else
sed -i 's@<family lang="zh-Hans">@<family lang="ja">\n <font weight="100" style="normal">Koruri-Thin.ttf</font>\n <font weight="300" style="normal">Koruri-Light.ttf</font>\n <font weight="400" style="normal">Koruri-Regular.ttf</font>\n <font weight="600" style="normal">Koruri-Semibold.ttf</font>\n <font weight="700" style="normal">Koruri-Bold.ttf</font>\n <font weight="800" style="normal">Koruri-Extrabold.ttf</font>\n <font weight="100" style="normal" fallbackFor="serif">Koruri-Thin.ttf</font>\n <font weight="300" style="normal" fallbackFor="serif">Koruri-Light.ttf</font>\n <font weight="400" style="normal" fallbackFor="serif">Koruri-Regular.ttf</font>\n <font weight="600" style="normal" fallbackFor="serif">Koruri-Semibold.ttf</font>\n <font weight="700" style="normal" fallbackFor="serif">Koruri-Bold.ttf</font>\n <font weight="800" style="normal" fallbackFor="serif">Koruri-Extrabold.ttf</font>\n </family>\n <family lang="zh-Hans">@g' $1
fi
}
#Function to replace Roboto font
replace_roboto() {
if [ $API -ge 31 ] ; then
#Android 12 and later
sed -i 's@style="normal">Roboto-Regular.ttf@style="normal">OpenSans-VariableFont.ttf@g' $1
sed -i 's@style="italic">Roboto-Regular.ttf@style="italic">OpenSans-Italic-VariableFont.ttf@g' $1
sed -i '[email protected]@Roboto-Regular.ttf@g' $1
fi
}
#Change fonts.xml file
remove_ja $MODDIR/system/etc/fonts.xml
add_ja $MODDIR/system/etc/fonts.xml
replace_roboto $MODDIR/system/etc/fonts.xml
#Goodbye, SomcUDGothic
sed -i '[email protected]@null.ttf@g' $MODDIR/system/etc/fonts.xml
sed -i '[email protected]@null.ttf@g' $MODDIR/system/etc/fonts.xml
#Goodbye, OnePlus Font
sed -i 's@OpFont-@Roboto-@g' $MODDIR/system/etc/fonts.xml
sed -i 's@NotoSerif-@Roboto-@g' $MODDIR/system/etc/fonts.xml
#Goodbye, OPLUS Font
sed -i 's@SysFont-Regular@Roboto-Regular@g' $MODDIR/system/etc/fonts.xml
sed -i 's@SysSans-En-Regular@Roboto-Regular@g' $MODDIR/system/etc/fonts.xml
#Goodbye, Xiaomi Font
/system/bin/sed -i -z 's@<family name="sans-serif">\n <!-- # MIUI Edit Start -->.*<!-- # MIUI Edit END -->@<family name="sans-serif">@' $MODDIR/system/etc/fonts.xml
sed -i '[email protected]@Roboto-Regular.ttf@g' $MODDIR/system/etc/fonts.xml
if [ -e /system/fonts/MiSansVF.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/MiSansVF.ttf
fi
#For MIUI 13+
sed -i 's@[email protected]@g' $MODDIR/system/etc/fonts.xml
if [ -e /system/fonts/MiSansVF_Overlay.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/MiSansVF_Overlay.ttf
fi
#Goodbye, vivo Font
sed -i '[email protected]@Koruri-Regular.ttf@g' $MODDIR/system/etc/fonts.xml
sed -i '[email protected]@Koruri-Regular.ttf@g' $MODDIR/system/etc/fonts.xml
if [ -e /system/fonts/HYQiHei-50.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/HYQiHei-50.ttf
fi
if [ -e /system/fonts/DroidSansFallbackBBK.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/DroidSansFallbackBBK.ttf
fi
if [ -e /system/fonts/DroidSansFallbackMonster.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/DroidSansFallbackMonster.ttf
fi
if [ -e /system/fonts/DroidSansFallbackZW.ttf ]; then
cp /system/fonts/Roboto-Regular.ttf $MODDIR/system/fonts/DroidSansFallbackZW.ttf
fi
#Copy fonts_slate.xml for OnePlus
opslate=fonts_slate.xml
if [ -e /system/etc/$opslate ]; then
cp /system/etc/$opslate $MODDIR/system/etc
#Change fonts_slate.xml file
remove_ja $MODDIR/system/etc/$opslate
add_ja $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Light.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Light.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Regular.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Regular.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Semibold.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Bold.ttf@g' $MODDIR/system/etc/$opslate
sed -i '[email protected]@Koruri-Extrabold.ttf@g' $MODDIR/system/etc/$opslate
fi
#Copy fonts_base.xml for OnePlus OxygenOS 11+
oos11=fonts_base.xml
if [ -e /system/etc/$oos11 ]; then
cp /system/etc/$oos11 $MODDIR/system/etc
#Change fonts_slate.xml file
remove_ja $MODDIR/system/etc/$oos11
add_ja $MODDIR/system/etc/$oos11
sed -i 's@NotoSerif-@Roboto-@g' $MODDIR/system/etc/$oos11
fi
#Copy fonts_base.xml for OnePlus OxygenOS 12+
oos12=fonts_base.xml
if [ -e /system/system_ext/etc/$oos12 ]; then
cp /system/system_ext/etc/$oos12 $MODDIR/system/system_ext/etc
#Change fonts_slate.xml file
remove_ja $MODDIR/system/system_ext/etc/$oos12
add_ja $MODDIR/system/system_ext/etc/$oos12
sed -i 's@NotoSerif-@Roboto-@g' $MODDIR/system/system_ext/etc/$oos12
fi