# Font Replacement (Mecha)



## HalosGhost (Jun 29, 2011)

Hey everyone! First off, I've been a lurker and small-time contributor on XDA for a while, but I must say, I'm starting to really enjoy the Rootzwiki community. Seems much more friendly and welcoming. I posted a similar tutorial for this on CM Forums and XDA for the OGD (A855), but having upgraded to a new phone, I figured I could provide an upgraded tutorial. Though this should theoretically work on all ROMs running any kernel, radio, recovery, etc. (and, for the most part, all phones). I've only tested this on Bare-bones stock Sense FroYo and CM7. Feel free to post if it works for other ROMs, confirmation of success is always appreciated 

In my many levels of nerdiness, I've discovered one of my many interests is typography, so I've taken to messing around with fonts quite a bit. Though I find the Droid Font Family to be decent, I have many fonts that are quite a bit better at doing the intended job. Thus, I set out to learn how to change the fonts on my phone quickly and as painlessly as possible. I've found that there are really four main ways to do this: custom app, root explorer (or another comparable file manager), through the command line or finally, through a flashable .zip. It turns out that Root Explorer is the best balance of power and ease, but everyone has their own preferences, so I'll walk through each possibility.

*Before you attempt this, standard disclaimers apply. I do not take any responsibility for your phone being bricked or bootlooping. Always make a NANDroid backup before you go messing around with system files!*

*Font Switcher:*
There are many apps in the Android market geared to this. The one linked to above is, if I were to use an app for this, the one I would pick. It's quite good at its job and the dev is very helpful and responsive. There's not much more to say here about this except that, none of these applications support changing all of the fonts on your phone. You'll only be able to replace Droid Sans, and with some of the applications, maybe Droid Serif. But you're generally stuck with Droid Serif and Droid Sans Mono. Furthermore, many of these apps do not allow you to pick your own font files.

Thus, we come to the second method...

*Root Explorer:*
I'm sure everyone reading this knows of Root Explorer by now, and I feel like for all the ability to customize things that you do with Root Explorer, it is the easiest for people to pick up.

So, if you have Root Explorer installed then installing custom fonts is actually quite easy. First off, you'll want to have the fonts names changed to match which font you wish the custom one to replace. For instance if you want Times as your replacement for Droid Serif, then you'll rename the Times font file to "DroidSerif-Regular.ttf" without the quotes of course (having said that, please don't use TNR on your phone... you'll make all of us typographers cry). If you want everything to look right, you need to have the right replacement for each file. So, there are two files for Droid Sans (Regular and Bold), four for Droid Serif (Regular, Bold, Italic, and Bold-Italic), and only regular for Droid Sans Mono. The names are as follows (DroidSans, DroidSans-Bold, DroidSerif-Regular, DroidSerif-Bold, DroidSerif-Italic, DroidSerif-BoldItalic, and DroidSansMono).

Now, once you have the fonts you want to have named accordingly (you do not need to replace all of them), place them somewhere on your SDcard. I tend to keep all the ones I might want in /sdcard/fonts. Once they are on your SD, navigate to that folder in Root Explorer, do Menu > Multi-Select and choose all of the ones you want. Then navigate to /system/fonts. You'll have to mount this as Read/Write (i.e., press the button in the upper-right hand corner to change mount flags). Then select paste.

Now comes the somewhat tedious part. If you reboot now, then either the fonts won't stick, or you'll just bootloop and have to revert to a backup. So, make sure you do this step. Long-press each of the files you just pasted and select Permissions. To insure that a bootloop doesn't happen and to make it most likely for the fonts to stick, the permissions flags should be r-xr-xr-x, which means the left and right columns should all be checked, but the center column should be blank.

Now, remount the system partition as Read-Only (i.e., press that upper-right hand button again). And if you really want to be safe about it, run "Fix Permissions" in ROM Manager, but this is not really necessary most of the time.

Then reboot, and voila! You should have your new fonts! However, I realize that there are a few of us Android people that hail from using operating systems with somewhat less silly implementations of linux. Thus, there is the third option...

*Command-line:*
Now, Root Explorer (along with all file managers) is essentially just a graphical interface to the Terminal in a lot of ways, so there isn't much that's different about it. There are a few advantages, if you don't want to rename your font files before you flash them, you don't have to, but if you don't then you'll have to copy them one by one rather than doing a batch operation. But, for those of us who are very comfortable from a command-line may love it. I use bash from a local terminal in ConnectBot, but the standard Terminal Emulator (with sh or any other shell) will be fine too.

Now, if you have your fonts on your sdcard, renamed already in a separate folder, then the task is very easy. Run the following commands, pressing return after each line (Use whatever path goes to your fonts rather than /sdcard/fonts/, but make sure you have the asterisk, and make sure that the directory you use *ONLY* has the fonts you want to use in it, nothing else). Keep in mind that the first cp command should only be run the first time you choose to flash new fonts, otherwise you'll overwrite your backups, and for this, you don't want to do that.

```
<br />
su -c 'mount -o remount,rw /dev/block/mmcblk0p25 /system'<br />
cp /system/fonts/* /sdcard/fonts/backups/<br />
cp /sdcard/fonts/*.ttf /system/fonts/<br />
su -c 'chmod +rx /system/fonts/*'<br />
su -c 'chmod -w /system/fonts/*'<br />
su -c 'mount -o remount,ro /dev/block/mmcblk0p25 /system'<br />
reboot
```
And voila! Your fonts should now be in place. Again, if you want to run "Fix Permissions" in ROM Manager before rebooting, then you certainly can. As a note of explanation, some ROMs have aliases that allow you to more easily remount the system, and some people (like myself, have done that manually), but the above commands will work on any Thunderbolt ROM regardless. Also, I use su -c rather than just logging into a su-session, because it is standard practice amongst linux users that nothing should be run with elevated permissions that doesn't need to be. But, logging in as su would work just as well (or even better yet, if you use bash, you can permanently alias su -c to sudo. Then you can pretend you have sudo installed on your phone!)

Should you ever choose to return to the default fonts, all you need to do is run the following commands (assuming you did the first cp command above the first time you changed fonts):

```
<br />
su -c 'mount -o remount,rw /dev/block/mmcblk0p25 /system'<br />
cp /sdcard/fonts/backups/* /system/fonts/<br />
su -c 'mount -o remount,ro /dev/block/mmcblk0p25 /system'<br />
reboot
```
Now, if you want to leave your font file-names unchanged, then most of the commands stay the same. It's the second cp command that changes, instead, you'll have to run it something like this. But you will have to do it for every font file you want to flash. After you've done that. The ending commands are the same.

```
<br />
cp /sdcard/fonts/LinLibG_Re.ttf /system/fonts/DroidSerif-Regular.ttf
```
I won't explain the flashable zip because it's pretty self-explanatory, the advantage is that it's simple and that it works on almost every Android phone. The draw-back is you either have to make it yourself, or you need to find someone that's already made it.

To facilitate people trying this out. I have created two archives. One is a standard Tar.Gz to be extracted to the SDcard, and from there you can do the steps mentioned above. The permissions of the fonts have already been changed, so you don't really need to worry about that step. The other is a flashable Zip to be installed through recovery as per usual. Both archives include the files to replace all seven fonts, and the replacements were hand-picked by me. The font families are: Liberation Sans for Droid Sans (R, B), Linux Libertine G for Droid Serif (R, B, I, BI), and Deja Vu Sans Mono for Droid Sans Mono. All seven of the ones included are Free and Open-Source, so they can be included here without issue, but I should say that I do not take credit for the creation of any of these fonts, nor the applications mentioned above. All credits to the coders.

Extractable Tar: Multi-upload | Dropbox Mirror
Flashable Zip: Multi-upload | Dropbox Mirror

Happy flashing, and all the best!

-HG


----------



## Grand Prix (Jun 11, 2011)

Thought I'd chime in and say very nice write up, that is all


----------



## HalosGhost (Jun 29, 2011)

Grand Prix said:


> Thought I'd chime in and say very nice write up, that is all


Thanks for the interest. If anyone knows anything about flashable Zip files, please contact me. For some reason unknown to me, I cannot make this file flash for the life of me. But the fonts I've provided allow for a much cleaner experience with Android, and I'd love to provide a simple way for others to share it.

All the best,

-HG


----------



## litso (Jun 7, 2011)

Great writeup! I figured out the Root Explorer method on my own when I got tired of crappy and non function apps on the OG Droid . Its amazing what you can accomplish when you're stubborn and just start poking around in system files!


----------



## HalosGhost (Jun 29, 2011)

litso said:


> Great writeup! I figured out the Root Explorer method on my own when I got tired of crappy and non function apps on the OG Droid . Its amazing what you can accomplish when you're stubborn and just start poking around in system files!


So true! Just wait. I'm going to be working here on porting the overclock module to Snapdragon for the Tbolt after I get some more free time. And then messing around in /etc/init.d will yield some really crazy things 

All the best,

-HG


----------



## wraithdu (Jul 25, 2011)

Post your updater-script and I'll take a look.


----------



## HalosGhost (Jun 29, 2011)

wraithdu said:


> Post your updater-script and I'll take a look.


PM sent with full current ZIP. Again, will edit OP with links once it's been confirmed working.

All the best,

-HG


----------



## HalosGhost (Jun 29, 2011)

wraithdu said:


> Post your updater-script and I'll take a look.


All thanks to wraithdu! Flashable zip file uploaded with dropbox mirror included (don't expect it to stay up forever, but it'll be up for a while).

All the best,

-HG


----------

