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

Designing for scalability – a startup perspective

What is scale? Is it the number of customers a company has? Is it the number of products that are sold? Is it the amount of revenue the company makes? Is it the amount of infrastructure one has? Or is it the number of features the product has? Well, it can be all of this or none of this. When an organization talks about scale it is not just a number. When an economist talks about it, again it’s not just a number. For an economist, the scale is about doing more with less. Scale is about perspective, about relationship between two or more variables that ultimately help you generate optimum value for your efforts.
Consider this, let’s say you are into making a lollipop. Selling 10 lollipops you earn $100 revenue of which $10 is you profit and $90 is the cost. When you increase you production you start selling 100 lollypops and earn $1000 revenue with $100 as your profit and $900 as cost. Did you really benefit from the scale here? In absolute terms, of course. In terms of ratios though,…

Featured in the 'Startup of the Week!' from SBC

We have recently been featured as the startup of the week on the StartupBootCamp Fintech Mumbai website. Just sharing the link to the original post by SBC here:

https://www.startupbootcamp.org/blog/2017/05/fintech-mumbai-startup-week-manage-fortune/


Will write more about the startup, what we do, how you may benefit from it and how has been our experience in separate posts. Till then, do check out our platform at ManageMyFortune.com

Asking for a slate that already is written into!

If I give you a slate or a notebook and a chalk or pencil, would you respond by complaining that it does not have anything written on it? Well that is how most educationist view technology as and that is what the problem with technology providers is.  We are so habituated to fast food instant noodle, that we want even our slates to be pre-written by someone else. The marketeers have lost the vision of utility of slate so much that they are still busy in selling slates with pre-written alphabets on them, and they are not giving you any chalk for your own writing as well.

Sounds absurd? Then remove slate and notebook, and put in its place the modern technology, computers, laptops, tablets and online learning solutions. In place of chalk and pencil, consider your ability to create and modify your own digital knowledge.  Of the hundreds of e-learning, online tutorials, online courses, are there any that focus on giving their learners the experience of creating knowledge on their own, put…