Tech Corner

Tech Corner Blog

In my blog you'll find a variety of technical topics that I've encountered over time as well as various issues that we encounter as we experience the internet. Spam in the form of comment spam and common email spam which we relentlessly fight is an issue that earns its own blog category. Scams is another topic that we need to be vigilent of which has a category to itself. If you see it here in a foreign language now you know why.


How do I install or remove font packages on Ubuntu Linux using dpkg and aptitude

In converting my development desktop from windows to Ubuntu linux I found that the linux install came with a completely different set of default fonts I used, and of course, was missing the custom ones I’d downloaded and installed on my windows PC. So, three  things had to happen:

  1. Copy my windows fonts to my linux pc
  2. Remove uneeded fonts from linux
  3. Install wanted fonts

Step I – Make a copy of your Windows font families.

  1. To access an make a copy of the windows fonts, on your win pc navigate through My Computer to your local disk, probably Local disk (C:) and open it.
  2. Select and open WINDOWS.  Using whatever medium you have available, make a copy of the Fonts folder.
  3. If necessary zip it up into a .Zip file for portability.
  4. Copy it to somewhere on your Linux PC.

Step 2 – Remove extraneous fonts from Linux PC.

In order for this to work you should first check, first make sure that both the ‘dpkg’ and ‘aptitude’ packages are installed on the Linux PC.  On the command line, type:
% which dpkg
% which aptitude

If either come back as not installed then download and install using your package manager. Also note that all the commands that I am running here are done at the Linux Terminal, Command line as root.  You don’t need to be root to do checks, but it just makes it easier.  To become root, enter:
% sudo -i
By default fonts are installed in subfolders under /usr/share/fonts.  In a command window navigating to that folder you should see something like:
% ls *
truetype: arphic      kochi       thai        ttf-bitstream-vera     ttf-indic-fonts-core
freefont  openoffice  ttf-arabeyes  ttf-dejavu        unfonts
type1: gsfonts
X11: 100dpi    75dpi  encodings  misc    Type1  util

The fonts will reside within subfolders, such as thai.  Before doing anything, just to be sure I didn’t mess up seriously I made a backup copy of the Fonts folder.
# cd /usr/share
# cp -r Fonts Fonts-o

Navigate into any of the fonts subfolder and do a list:
# cd Fonts/truetype/thai
# ls -l

Assuming the list is fonts you want to remove, copy the name of one to remove and use the dpkg command to get the name of the font family.  If you have a font called sawasdee.ttf, then do:
# dpkg -S sawasdee.ttf
It should return the name of the font family.  When you then do the removal using aptitude it will remove all the fonts named under that family.  To remove the font family, enter:
# aptitude purge sawasdee.ttf
As it starts to process you will get a confirmation request which you respond affirmatively to.

Step 3 – Installing new fonts on Ubuntu Linux

With your folder of fonts previously copied to your desktop this is unbelievably easy.

Rename the windows folder to something that makes sense to you, say custom, then copy custom to /usr/share/fonts:
# cd $your_path/Desktop
# mv Fonts custom
# mv custom /usr/share/fonts (of course make sure there isn't already a folder called custom)
# fc-cache -f -v (or if you are not root use 'sudo fc-cache -f -v')

It will take a few seconds or so to process, but that it is.  Restart whatever program you are using where you need to use your fonts to get the new list.

This entry was posted in Operating system - Linux. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>