How to change or add system fonts in android emulator

I wanted to install Bengali fonts in my Android device. I tried different ways to add Bengali font support in my Android device. And finally I ended up with fonts installed in Android emulator.

Android emulator with Bengali fonts

I followed different blogs where many people explained how to add system fonts in android devices. Some people say that we can install system fonts without rooting the device. On the other hand there are people who believes that the android device must be rooted to make changes to system fonts. I believe that the device must be rooted. Because all my attempts were unsuccessful with my un-rooted device.

Finally, I decided to install or change system font of Android emulator. I could replace system fonts using adb shell. But the problem was that the changes were not persistent. That is, system files are restored when the emulator is restarted. And that was a new challenge on my way. Please find the steps below that I followed to overcome this new challenge.

Note that we need a linux PC to execute the following steps.

  1. Extract system.img using uyaffs. You will find system.img in your ‘SDK_INSTALLATION_DIR/platforms/android-2.2/images/’ directory. Download the file unyaffs2 and change permission to add execute support. Now create a new folder where you want to extract all contents of system.img. Go to that folder and extract contents using the command ‘./some/path/to/unyaffs /another/path/to/system.img’. This will extract all contents in the current folder.
  2. Add or modify contents in corresponding locations. I replaced /system/fonts/DroidSansFallback.ttf with SiyamRupali.ttf (or SolaimanLipi.ttf) to add Bengali font support. Since I wanted to install Android Market application in the emulator I did edit /system/build.prop file (added # at the start of the text ‘ro.config.nocheckin=yes’). Also I followed necessary steps to install Android Market application in emulator here. Though this did not work for me, I would request you to read those steps.
  3. Re-pack system.img using mkfs.yaffs2.x86. You may download mkfs.yaffs2.x86 from here or here if the first link is not reachable. But I did not test those. The command to pack contents will be something similar to ‘./some/path/to/mkfs.yaffs2.x86 /your/image/dir/ /your/newimage/path/newimage.img’
  4. Now that you have created a modified version of system.img its time to run avd using that new image. Copy newimage.img to Android SDK installation location from where you copied system.img earlier to extract. Rename existing system.img to system.img.orig. Now rename newimage.img to system.img. Start avd and check if everything is OK.

Android Market in emulator SDK 2.2

2 Comments »

  1. RG said

    Rubel,
    Thanks for the blog. But no matter how many times I tried the re-packing does not seem to work. In fact there are two issues that I found. First the unyaffs on Linux left out all the *.lnk files in the bin directory. I found this out since I compared the unyaffs output on windows with that on Linux. Second, even if all the files are same (with or without the lnk files) the yaffs2 on Linux produced file (new system.img) of slightly different size (100 – 200bytes) and the image file failed to be loaded using AVD manager (or through eclipse). I see that the emulator hangs at AVD-manager before loading the system image and if eclipse is used I see an error where the launch had an error and it got cancelled as the following message sequence depict.

    [2011-12-08 19:34:41 – UITestApp] Android Launch!
    [2011-12-08 19:34:41 – UITestApp] adb is running normally.
    [2011-12-08 19:34:41 – UITestApp] Performing ui.test.app.UITestAppActivity activity launch
    [2011-12-08 19:34:41 – UITestApp] Automatic Target Mode: launching new emulator with compatible AVD ‘eSlate1’
    [2011-12-08 19:34:41 – UITestApp] Launching a new emulator with Virtual Device ‘eSlate1’
    [2011-12-08 19:34:50 – UITestApp] New emulator found: emulator-5554
    [2011-12-08 19:34:50 – UITestApp] Waiting for HOME (‘android.process.acore’) to be launched…
    [2011-12-08 19:36:08 – UITestApp] emulator-5554 disconnected! Cancelling ‘ui.test.app.UITestAppActivity activity launch

    • I did face such hang issue when I unpacked in windows and repack in linux. Then I had to unpack and repack in linux environment. Please use the same tools that I used to unpack and repack system.img. It did work in my place.

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: