Skip to main content

Installing fonts on Android, simple yet unnecessarily tricky

Most android devices come with set of fonts already installed for all the general purpose use with variety of styles and various languages. There is also something called 'fallback' font which ensures that in case a required font is not available, the system falls back to this font with wide range of characters and more generic style to display the text. But sometimes, you really want to use that specific font which is not there on the device or you just 'have' to use a some non-english font because the system by default does not have the font for the language you wish to use. Though upfront it looks like a simple task of installing the font, unfortunately android does not yet provide a simple way of doing it in user space. It is possible for an application to provide a custom font and use it within the application, but that's not really installing it on the device, its applicable only within the app.

Recently while working with some Indic languages on android, I was faced with this problem where I had to display Kannada and Gujarati in browser, but my old ICS device, did not have any Gujarati or Kannada font by default. So I started looking for an app for installing fonts. Interestingly every app I could find required the phone to be rooted. Rooting the device for such a simple task! But anyway had to do it, and that's actually not very difficult with ready to use apps like vroot. Next downloaded one of the popular font installing app, iFont. Good thing about iFont is it provides numerous fonts by default, so if any of them suites your purpose, you may go ahead with it. But if the font you want is not listed, you need to add it to the app and then install it from there. So went ahead and installed the Gujarati font using iFont, it gave some sort of warning that things may break somehow, which I of course ignored. Reboot. And things did break down. All of the text on my screen was just vanished, except for few bits of Gujarati somewhere. So following just the icons, I started the iFont again and somehow figured out the section where my font was listed and tried uninstalling it. Reboot. And everything was back. That was scary for a simple font addition.

Later I figured out from the application logs, what exactly this iFont did. It simply took the backup of DroidSansFallback.ttf font on the system and replaced it with my font. It meant all the characters (glyphs) in fallback font other than Gujarati were gone. For weird reasons, my system was looking into DroidSansFallback.ttf for displaying the normal English text on screen. Hence all the text was vanished. In any case whatever iFont was doing did not seem promising and it also appeared that most available font installers did the same thing. So I fell back to look for a manual procedure.

In general font installing involves just two things, copying the font file to specific location and sourcing some configuration file to declare few properties to the system. On desktops, these things mostly happen automatically, or at the most you have to click the install button and it does everything required. The basic procedure on android is also similar, just that there is no direct button yet. So once the phone/device is rooted, this is what you need to do:

1. Copy the font file to /system/fonts/ directory.
2. Add an entry in some xml file for the font.

Of these, step '1' can be done in multiple ways. but most commonly you will have to use adb shell to get access to the device file system. There is enough documentation on installing android developer environments and using adb shell over internet depending upon your operating system. So not repeating all that. So once connected by adb shell, you can simply use 'adb push MyFont.ttf  /system/fonts/MyFont.ttf' to push the font file from computer to the direct path on the phone. Or you may also use 'adb shell' to get shell access of the android system. By default android will not provide 'cp' command, so you may have to use 'cat inputfile -> outputfile' method to copy. Or you may also download 'busybox' to get ease of using all the general purpose linux commands on android shell. 

For the step '2', again we do not have luxury of fontconfig like tool for configuring everything. So you need to check the font properties, such as 'font-family' on your own, any font viewer on the desktop system would be able to show that much. Now if you have already done the 'busybox' thing mentioned earlier, you may directly use 'vi editor' on the 'adb shell' or you may get the xml file copied to the desktop machine by 'adb pull file', edit on desktop and then push to the device. The file you need to look for is '/system/etc/fallback_fonts.xml'. See the file '/system/etc/system_fonts.xml' for more details on format and possible parameters. Save the file on the device after making proper entries for your font and your font would be installed on the system after reboot.

If you are already used to accessing and editing android system files, this should be a simple two step procedure, otherwise you may need a little getting used to and few google searches to get your way to safely accessing and editing system files. Sorry for not giving the step-by-step guide on this, but that was never the purpose.

Ideally, there shouldn't have been a need to root the phone in first place for simple font installation. It should have been possible to install the font in user domain by simply keeping font file in some user accessible location and a related xml file for describing it. Did not get the logic behind keeping it so inaccessible to common people. Anyone would have done a simple app to give user interface to it. I may not be aware, but if anyone knows better on this, I would love to know it. If indeed there is no other proper way than rooting the device, I think android should give it a serious thought to improve font management, even integrating fontconfig by default may be enough for this.

Apart from that, the apps like iFont can also do away with dangerously insane modification of fallback font. It virtually disables everything that needs to fall back, and given the number of languages, a lot of people do need to fall back for basic viewing of text. Anyway the app needs root access, so why not use it responsibly and make only intended changes to simple configuration files instead of other shortcuts. Hopefully the upcoming versions of android will have better font management by default, especially since use of non-english languages is consistently growing on mobile platform where this feature could become increasingly critical.

[Also read at: GnowTantra]


Popular posts from this blog

PVR is so wierd!

Yesterday we went second time to a mall bit far from office to complete the earlier failed mission of watching this 3D movie, Clash of the Titans. On ticket counter, we were first told that evening show was house full. Then we asked for a night show, and were told there isn't any show then and the gentleman handed us the pamphlet of all movie schedules. We checked on the nearby digital kiosk and also on the printed schedule to be sure of the show timings. Then went to second counter, and asked the lady for the night show tickets, and without any problem got the tickets for back seats. In fact this show was hardly 20% full, wonder how the evening show became houseful.

But the biggest wonder/blunder is yet to come. On the entrance we were stopped for having a laptop bag along with (we had went straight after the office). In spite of having checked the bag, we were not allowed, because laptops were not allowed inside! Then we asked for keeping it at the baggage counter. But then, the…

My first web blog

This may be the common first post for every blogger. And even I want to say,

Hello everybody,

I have seen that blogging has been a crucial subject for many professionals and internet savvy people. Thanks to all of those whose concern encouraged me to create my first blog.
Now lets see how it works for me.


Lohit, Fedora and Community

First: _Some updates on Lohit Malayalam fonts_
Recently, there has been a huge agitation by Malayalam community about the bugs in the f9 final version of lohit fonts. You can get a glimpse of it here. Most of these were either last minute hickups or not reported at all until then. But whatever it was, the final product could not be buggy. So, within a short span of time, all these bugs (#444559, #444561, #444563) were fixed for Lohit and tagged into for the f9 final. So the version in fedora and latest upstream, lohit-2.2.1 is free of all these bugs. Malayalam users would be able to find the fixes in the following screenshot.
Second: _Some comments on the events going around_
After working for so many years on so many languages for so many different tools and applications, sometimes for some organizations, sometimes just out of passion, I (or should I say we, the language computing guys) have developed this immense love for all the languages of India. They are all rich in their heritage,…