├── tool
├── libfreetype.so
├── libfontconfig.so
├── libfreetype.so.6
├── fonts.conf
├── libfontconfig.so.1
├── fc-scan
├── libfreetype.so.6.19.0
└── libfontconfig.so.1.13.0
├── META-INF
└── com
│ └── google
│ └── android
│ ├── updater-script
│ └── update-binary
├── .gitmodules
├── .gitignore
├── module.prop
├── README.md
└── customize.sh
/tool/libfreetype.so:
--------------------------------------------------------------------------------
1 | libfreetype.so.6
--------------------------------------------------------------------------------
/tool/libfontconfig.so:
--------------------------------------------------------------------------------
1 | libfontconfig.so.1
--------------------------------------------------------------------------------
/tool/libfreetype.so.6:
--------------------------------------------------------------------------------
1 | libfreetype.so.6.19.0
--------------------------------------------------------------------------------
/tool/fonts.conf:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/tool/libfontconfig.so.1:
--------------------------------------------------------------------------------
1 | libfontconfig.so.1.13.0
--------------------------------------------------------------------------------
/META-INF/com/google/android/updater-script:
--------------------------------------------------------------------------------
1 | #MAGISK
2 |
--------------------------------------------------------------------------------
/tool/fc-scan:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JingMatrix/MagiskFonts/HEAD/tool/fc-scan
--------------------------------------------------------------------------------
/tool/libfreetype.so.6.19.0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JingMatrix/MagiskFonts/HEAD/tool/libfreetype.so.6.19.0
--------------------------------------------------------------------------------
/tool/libfontconfig.so.1.13.0:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JingMatrix/MagiskFonts/HEAD/tool/libfontconfig.so.1.13.0
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "fontconfig"]
2 | path = fontconfig
3 | url = https://gitlab.freedesktop.org/fontconfig/fontconfig
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | system
2 | system/fonts/*.ttf
3 | product/fonts/*.ttf
4 | system/etc/fonts.xml
5 | product/etc/fonts.xml
6 | MagiskFonts.zip
7 |
--------------------------------------------------------------------------------
/module.prop:
--------------------------------------------------------------------------------
1 | id=custom_fonts
2 | name=Custom Fonts
3 | version=1.1
4 | versionCode=2
5 | author=JingMatrix
6 | description=Add custom fonts for system-wise usage
7 |
--------------------------------------------------------------------------------
/META-INF/com/google/android/update-binary:
--------------------------------------------------------------------------------
1 | #!/sbin/sh
2 |
3 | #################
4 | # Initialization
5 | #################
6 |
7 | umask 022
8 |
9 | # echo before loading util_functions
10 | ui_print() { echo "$1"; }
11 |
12 | require_new_magisk() {
13 | ui_print "*******************************"
14 | ui_print " Please install Magisk v20.4+! "
15 | ui_print "*******************************"
16 | exit 1
17 | }
18 |
19 | #########################
20 | # Load util_functions.sh
21 | #########################
22 |
23 | OUTFD=$2
24 | ZIPFILE=$3
25 |
26 | mount /data 2>/dev/null
27 |
28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29 | . /data/adb/magisk/util_functions.sh
30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31 |
32 | install_module
33 | exit 0
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Magisk
2 |
3 | This module configures fonts that you add for system-wise usage.
4 |
5 | ## Usage
6 |
7 | 1. Clone this repository: `git clone --depth=1 https://github.com/JingMatrix/MagiskFonts`;
8 | 2. Create a directory `system/fonts`: `mkdir -p system/fonts`;
9 | 3. Put your fonts inside `system/fonts`, currently `ttf` files work well;
10 | 4. Pack and install the zip module: `7z a MagiskFonts.zip META-INF customize.sh module.prop system tool`.
11 |
12 | ## Why do I need it?
13 |
14 | Add fonts for applications like browsers and e-books readers, such as `Google Play Books`.
15 |
16 | For problems of rendering fonts in browsers on Android 15+, please refer to [this issue](https://github.com/JingMatrix/FontLoader/issues/1).
17 |
18 | ## Reference
19 |
20 | Parser location in [Android Code Search](https://cs.android.com/): [frameworks/base/graphics/java/android/graphics/FontListParser.java](https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/graphics/java/android/graphics/FontListParser.java).
21 |
--------------------------------------------------------------------------------
/customize.sh:
--------------------------------------------------------------------------------
1 | #! sh
2 |
3 | if [ -z $MAGISK_VER ]; then
4 | echo "If you see this in the installation process, please cancel it."
5 | ui_print() { echo "$@" 1>&2; }
6 | set_perm_recursive() { return; }
7 | MODPATH=$PWD
8 | fi
9 |
10 | set_perm_recursive $MODPATH/tool root root 700 700
11 | fscan() {
12 | FONTCONFIG_PATH=$MODPATH/tool LD_LIBRARY_PATH=$MODPATH/tool $MODPATH/tool/fc-scan "$@"
13 | }
14 |
15 | generate_config() {
16 |
17 | if [ ! -f $font_config_file ]; then
18 | return 0
19 | fi
20 |
21 | # tmpfile="$MODPATH/part_tmp.xml"
22 | ui_print "Pull original $font_config_file"
23 | mkdir -p $MODPATH/$font_dir/etc
24 | # awk '{print >out}; //{out="'$tmpfile'"}' out=$MODPATH/$font_config_file $font_config_file
25 | sed "/^/q" $font_config_file >$MODPATH/$font_config_file
26 | sed -i '$ d' $MODPATH/$font_config_file
27 | echo "" >>$MODPATH/$font_config_file
28 |
29 | font_family_config=$sep'\n'$sep$sep'%{file}\n'$sep'\n'
30 | alia_config=$sep'\n'
31 |
32 | cd $MODPATH/$font_dir/fonts/
33 | for fontfile in *.*; do
34 | ui_print "Add custom font $fontfile"
35 | fscan -f "$font_family_config" "$fontfile" >>$MODPATH/$font_config_file
36 | # fscan -f "%{family}" "$fontfile" | grep ',' >/dev/null
37 | # if [ $? -eq 0 ]; then
38 | # fscan -f "$alia_config" "$fontfile" >>$MODPATH/$font_config_file
39 | # fi
40 | done
41 | cd /
42 |
43 | # cat $tmpfile >>$MODPATH/$font_config_file
44 | # rm $tmpfile
45 | echo "$config_end_mark>" >>$MODPATH/$font_config_file
46 | cp $MODPATH/$font_config_file /data/local/tmp
47 | ui_print "New $font_config_file generated"
48 | ui_print ""
49 | }
50 |
51 | ui_print "Module directory is $MODPATH"
52 |
53 | # locale=' lang="zh-Hans"'
54 | locale=''
55 |
56 | font_dir="/system"
57 | font_config_file="$font_dir/etc/fonts.xml"
58 | config_end_mark="familyset"
59 | sep="\t"
60 | generate_config
61 |
62 | font_dir="/system"
63 | font_config_file="$font_dir/etc/font_fallback.xml"
64 | config_end_mark="familyset"
65 | sep=" "
66 | generate_config
67 |
--------------------------------------------------------------------------------