Skip to content

Commit

Permalink
Use fc-scan for proper font name
Browse files Browse the repository at this point in the history
One should build fontconfig before install
  • Loading branch information
JingMatrix committed Dec 7, 2022
0 parents commit 8b1c5cf
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
system/fonts/*.ttf
system/etc/fonts.xml
tool
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "fontconfig"]
path = fontconfig
url = https://gitlab.freedesktop.org/fontconfig/fontconfig
33 changes: 33 additions & 0 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/sbin/sh

#################
# Initialization
#################

umask 022

# echo before loading util_functions
ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}

#########################
# Load util_functions.sh
#########################

OUTFD=$2
ZIPFILE=$3

mount /data 2>/dev/null

[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk

install_module
exit 0
1 change: 1 addition & 0 deletions META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#MAGISK
12 changes: 12 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! bash

pushd fontconfig
rm -rf build
meson build
ninja -C build
cp build/fc-scan/fc-scan build/src/libfontconfig.so* ../tool
echo '<fontconfig></fontconfig>' > tool/fonts.conf
popd
rm -rf system/etc
rm -rf MagiskFonts.zip
7z a MagiskFonts.zip META-INF customize.sh module.prop system tool
26 changes: 26 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#! sh

if [ -z $MAGISK_VER ]; then
echo "If you see this in the installation process, please cancel it."
ui_print() { echo "$@" 1>&2; }
set_perm_recursive() { return; }
MODPATH=$PWD
fi

ui_print "Pull original fonts.xml"
mkdir -p $MODPATH/system/etc
head -n -1 $(magisk --path)/.magisk/mirror/system/etc/fonts.xml >$MODPATH/system/etc/fonts.xml

set_perm_recursive $MODPATH/tool root root 700 700

ui_print "Injecting custom fonts"
for fontfile in $(ls $MODPATH/system/fonts); do
fontname=$(FONTCONFIG_PATH=$MODPATH/tool LD_LIBRARY_PATH=$MODPATH/tool $MODPATH/tool/fc-scan -f '%{postscriptname}' $MODPATH/system/fonts/$fontfile)
ui_print "Add custom fonts $fontname"
echo ' <family name="'$fontname'">' >>$MODPATH/system/etc/fonts.xml
echo " <font>$fontfile</font>" >>$MODPATH/system/etc/fonts.xml
echo " </family>" >>$MODPATH/system/etc/fonts.xml
done

echo "</familyset>" >>$MODPATH/system/etc/fonts.xml
ui_print "New fonts.xml generated"
1 change: 1 addition & 0 deletions fontconfig
Submodule fontconfig added at c8f621
6 changes: 6 additions & 0 deletions module.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=costume_fonts
name=Costume Fonts
version=1.0
versionCode=1
author=Jing Matrix
description=Add costume fonts for systemwise usage

0 comments on commit 8b1c5cf

Please sign in to comment.