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]

Comments

Popular posts from this blog

Unicode 5.1 release and Indic changes

Unicode 5.1 release was announced earlier this month on 4th April. Here I have put a diff taken of Unicode 5.1 character database against that of Unicode 5.0. My buddy, Parag also did a nice job of summarizing the Indic specific changes, that I am trying to restate now. So, here go the updates on Indian scripts UCD: A. New Indic Scripts Added to Unicode: 1. LEPCHA: Lepcha is a language spoken by the Lepcha people in Sikkim in India,and parts of Nepal and Bhutan. The Lepcha script (also known as "róng") is a syllabic script which has a lot of special marks and requires ligatures. Its genealogy is unclear. Early Lepcha manuscripts were written vertically, a sign of Chinese influence. Lepcha is considered to be one of the aboriginal languages of the area in which it is spoken. Total number of speakers numbers near 50,000. Unicode Range =>U1C00 to U1C4F Chart URL => http://www.unicode.org/charts/PDF/U1C00.pdf 2. OL-CHIKI: The Ol Chiki script, also known

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

The Kreate logo is done!

It's been several months now that we have been brainstorming about the logo and caption. We all were thinking on lines of both creativity and value offerings. Gautam was continuously thinking on lines of how to communicate imagination and implementation parts simultaneously, the left and right of the brain. Many tag-lines popped up, but always there was something missing. Finally, me and joy took up these two words from Gautam and simply put a dot between them. It sounded so crisp! 'Imagination.Implementation'! Meanwhile, many of us were trying to come up with the design ideas. For me, playing with various shapes of 'K' and using whatever minuscule knowledge of calligraphy/typography I had, became my regular pass-time to keep myself awake in gaseous classrooms. In later stages, I got stuck on the idea of creating a character out of K that can personify the values we worked on so long. Finally emerged the k-man that is so carefree, cheerful, and aesthetic. Joy took t