User Tools

Site Tools


android:lineageos-18.1-trebuchet-custom-font

This is an old revision of the document!


LineageOS 18.1/Trebuchet Custom Font

Since LineageOS 17 there's something called «Styles & Wallapers». I don't how it works on other ROM's, but in LineageOS 18.1, at least, it lets you change (among other stuff) the operating system font.

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.

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:

hero2ltexx:/system/product/fonts # ls -lahtr
total 10M
-rw-r--r--  1 root root 137K 2008-12-31 22:00 Rubik-Regular.ttf
-rw-r--r--  1 root root 142K 2008-12-31 22:00 Rubik-MediumItalic.ttf
-rw-r--r--  1 root root 140K 2008-12-31 22:00 Rubik-Medium.ttf
-rw-r--r--  1 root root 140K 2008-12-31 22:00 Rubik-Italic.ttf
-rw-r--r--  1 root root 143K 2008-12-31 22:00 Rubik-BoldItalic.ttf
-rw-r--r--  1 root root 140K 2008-12-31 22:00 Rubik-Bold.ttf
-rw-r--r--  1 root root 576K 2008-12-31 22:00 Lato-Regular.ttf
-rw-r--r--  1 root root 679K 2008-12-31 22:00 Lato-MediumItalic.ttf
-rw-r--r--  1 root root 621K 2008-12-31 22:00 Lato-Medium.ttf
-rw-r--r--  1 root root 629K 2008-12-31 22:00 Lato-Italic.ttf
-rw-r--r--  1 root root 604K 2008-12-31 22:00 Lato-BoldItalic.ttf
-rw-r--r--  1 root root 574K 2008-12-31 22:00 Lato-Bold.ttf
drwxr-xr-x 10 root root 4.0K 2008-12-31 22:00 ..
[...]
-rw-r--r--  1 root root 113K 2022-06-25 13:07 IBMPlexMono-Bold.ttf
-rw-r--r--  1 root root 119K 2022-06-25 13:07 IBMPlexMono-BoldItalic.ttf
-rw-r--r--  1 root root 119K 2022-06-25 13:07 IBMPlexMono-Italic.ttf
-rw-r--r--  1 root root 112K 2022-06-25 13:07 IBMPlexMono-Medium.ttf
-rw-r--r--  1 root root 119K 2022-06-25 13:07 IBMPlexMono-MediumItalic.ttf
-rw-r--r--  1 root root 111K 2022-06-25 13:07 IBMPlexMono-Regular.ttf
[...]

Ideally, you must copy Bold, Regular and Medium (with their respective Italic variations), because that what seems easier to deal with. But your mileage my vary and you may also want to play a little with font sizes.

After copying those fonts over to the cellphone, you'll soon notice they still don't appear at the screens I've showed atop. Yes, there are some additional steps.

Next up, we must edit a /system/product/etc/fonts-costumization.xml file:

<?xml version="1.0" encoding="utf-8"?>
<fonts-modification version="1">
    <family customizationType="new-named-family" name="lato">
        <font weight="400" style="normal">Lato-Regular.ttf</font>
        <font weight="400" style="italic">Lato-Italic.ttf</font>
        <font weight="500" style="normal">Lato-Medium.ttf</font>
        <font weight="500" style="italic">Lato-MediumItalic.ttf</font>
        <font weight="700" style="normal">Lato-Bold.ttf</font>
        <font weight="700" style="italic">Lato-BoldItalic.ttf</font>
    </family>
    <alias name="lato-medium" to="lato" weight="500" />
    <alias name="lato-bold" to="lato" weight="700" />

    <family customizationType="new-named-family" name="rubik">
        <font weight="400" style="normal">Rubik-Regular.ttf</font>
        <font weight="400" style="italic">Rubik-Italic.ttf</font>
        <font weight="500" style="normal">Rubik-Medium.ttf</font>
        <font weight="500" style="italic">Rubik-MediumItalic.ttf</font>
        <font weight="700" style="normal">Rubik-Bold.ttf</font>
        <font weight="700" style="italic">Rubik-BoldItalic.ttf</font>
    </family>
    <alias name="rubik-medium" to="rubik" weight="500" />
    <alias name="rubik-bold" to="rubik" weight="700" />

    <family customizationType="new-named-family" name="ibmplexmono">
        <font weight="400" style="normal">IBMPlexMono-Regular.ttf</font>
        <font weight="400" style="italic">IBMPlexMono-Italic.ttf</font>
        <font weight="500" style="normal">IBMPlexMono-Medium.ttf</font>
        <font weight="500" style="italic">IBMPlexMono-MediumItalic.ttf</font>
        <font weight="700" style="normal">IBMPlexMono-Bold.ttf</font>
        <font weight="700" style="italic">IBMPlexMono-BoldItalic.ttf</font>
    </family>
    <alias name="ibmplexmono-medium" to="lato" weight="500" />
    <alias name="ibmplexmono-bold" to="lato" weight="700" />
</fonts-modification>

Note the last family entry. Change that accordingly.

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.

References

android/lineageos-18.1-trebuchet-custom-font.1656180021.txt.gz · Last modified: 2022/06/25 15:00 by prppedro