Both sides previous revisionPrevious revisionNext revision | Previous revision |
android:lineageos-18.1-trebuchet-custom-font [2022/06/25 15:00] – prppedro | android:lineageos-18.1-trebuchet-custom-font [2022/06/25 16:11] (current) – prppedro |
---|
| |
However, the default options (currently Android default, Noto Sans, Rubik and Lato) might not be of your taste. Personally, I wanted to use IBM Plex, so that's what I'm using as example. With some tweaking, I think it can work for any fonts you might want to use. | However, the default options (currently Android default, Noto Sans, Rubik and Lato) might not be of your taste. Personally, I wanted to use IBM Plex, so that's what I'm using as example. With some tweaking, I think it can work for any fonts you might want to use. |
| |
| Before we start, **make sure you have the tools to work with**. In our particular case, **ADB**, for sure, but also ''build-tools'' of Android SDK. On Debian-based operating systems, you can install them using the following command: ''apt install android-sdk-build-tools android-sdk-platform-tools''. Also, make sure you can **run ADB as root** (''adb root & adb shell''). **The phone's root filesystem must also be writable** (''mount -o remount,rw /''). |
| |
So, the first thing we should do is to copy those fonts to the phone. Again, I don't know about other ROMs, but, in our case, it suffices to ''adb push'' the TTF's (or OTF's) to ''/system/product/fonts.'' Preferably, you will end up with a list like this: | So, the first thing we should do is to copy those fonts to the phone. Again, I don't know about other ROMs, but, in our case, it suffices to ''adb push'' the TTF's (or OTF's) to ''/system/product/fonts.'' Preferably, you will end up with a list like this: |
<font weight="700" style="italic">IBMPlexMono-BoldItalic.ttf</font> | <font weight="700" style="italic">IBMPlexMono-BoldItalic.ttf</font> |
</family> | </family> |
<alias name="ibmplexmono-medium" to="lato" weight="500" /> | <alias name="ibmplexmono-medium" to="ibmplexmono" weight="500" /> |
<alias name="ibmplexmono-bold" to="lato" weight="700" /> | <alias name="ibmplexmono-bold" to="ibmplexmono" weight="700" /> |
</fonts-modification> | </fonts-modification> |
</code> | </code> |
| |
The font is now installed. **But**, unless we deploy what's called an //overlay//, __the font still won't appear__ on **Styles & Wallpapers**. So, there's still a last (and rather dull) step to go. | The font is now installed. **But**, unless we deploy what's called an //overlay//, __the font still won't appear__ on **Styles & Wallpapers**. So, there's still a last (and rather dull) step to go. |
| |
| LineageOS project is opensource, so we can clone their overlays repository: ''git clone https://github.com/LineageOS/android_packages_overlays_Lineage''. What interests us is, obviously, inside ''fonts'' folder. You can copy any of the ''Font*Overlay'' subfolders to ''src'' (or whatever you want to call it, but ''src'' is more convenient because we're going to run a script which «compiles» that overlay. |
| |
| Inside ''src'' there are some files and folders. Go through them and change them as per needed. Here's mine, for reference: {{ :android:src-ibmplex.tar.gz |}}. |
| |
| Now, we must generate the overlay APK file. For that, I modified [[https://github.com/Kolodez2106/HelloWorld-app-compiled-in-bash/blob/main/make.sh|a script]] written by the GitHub user ''Kolodez2106''. As we don't need to compile anything, ''javac'' won't -- God bless! -- cross our paths, but we're still going to need ''jarsign'', so Java must be installed. The shell script goes more or less as follows: |
| |
| <code> |
| #!/bin/bash |
| |
| rm -v -f -r ./obj |
| rm -v -f -r ./bin |
| rm -v -f -r ./key |
| mkdir ./obj |
| mkdir ./bin |
| mkdir ./key |
| aapt package -v -f -m -S ./src/res/ -M ./src/AndroidManifest.xml -I /usr/lib/android-sdk/platforms/android-23/android.jar # you may need to replace "/usr/lib/android-sdk/platforms/android-23/android.jar" here and in the subsequent commands |
| aapt package -f -M ./src/AndroidManifest.xml -S ./src/res/ -I /usr/lib/android-sdk/platforms/android-23/android.jar -F ./bin/FontIBMPlexMonoOverlay.unsigned.apk ./bin # it is important that the ./bin/ directory does not contain any files except for classes.dex when this command starts |
| keytool -genkeypair -validity 10000 -dname "CN=YOURNAME, OU=YOURNAME, O=YOURNAME, C=YOURCOUNTRY" -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -alias myalias -keyalg RSA |
| jarsigner -keystore ./key/mykey.keystore -storepass mypass -keypass mypass -signedjar ./bin/FontIBMPlexMonoOverlay.signed.apk ./bin/FontIBMPlexMonoOverlay.unsigned.apk myalias |
| zipalign -f 4 ./bin/FontIBMPlexMonoOverlay.signed.apk ./bin/FontIBMPlexMonoOverlay.apk |
| </code> |
| |
| If you're using Windows or any UNIX flavor which simply stores that stuff in a different place I can't help you much, but you can create a Batch or a modified shell script with not much effort, because those are the commands you need. |
| |
| After running the script, you'll end up with the file ''bin/FontIBMPlexMonoOverlay.apk''. Run ''adb shell'' and create a folder at ''/system/product/overlay'' called something like ''LineageIBMPlexMonoFont'' (I called mine that to follow the standard dictated by the other folder names). Exit the shell and then run ''adb push bin/FontIBMPlexMonoOverlay.apk /system/product/overlay/LineageIBMPlexMonoFont''. |
| |
| After restarting your phone, you should be able to pick the font at **Styles & Wallpapers**. |
| |
===== References ===== | ===== References ===== |
* https://www.reddit.com/r/LineageOS/comments/r2j0wm/custom_fonts_in_trebuchet_launcher/ | * https://www.reddit.com/r/LineageOS/comments/r2j0wm/custom_fonts_in_trebuchet_launcher/ |
* https://source.android.com/devices/architecture/rros | * https://source.android.com/devices/architecture/rros |
| * https://github.com/Kolodez2106/HelloWorld-app-compiled-in-bash/blob/main/make.sh |
| * https://source.android.com/devices/automotive/hmi/car_ui/fonts |
| |