Wednesday, June 3, 2015

HOWTO Install Web fonts in Debian

1. First of all we will need to download the Fonts that you want to install on the Server.
For example:
ximena@xdev:~$ wget -O metalmania.woff http://themes.googleusercontent.com/static/fonts/metalmania/v2/_MPduYXiaptg6GQ2M6AHtIbN6UDyHWBl620a-IRfuBk.woff

Now, we will need to download the converter and convert the Fonts from .woff to .ttf (TrueType):

2. Download the converter:
ximena@xdev:~$ wget https://raw.github.com/hanikesn/woff2otf/master/woff2otf.py
ximena@xdev:~$ chmod u+x woff2otf.py

3. Convert the files:
ximena@xdev:~$ ./woff2otf.py metalmania.woff metalmania.ttf

Hint (1): you need to have python3 installed on your Server.

Now we will install the Font and Rebuild the Font Cache:

4. Install the fonts
ximena@xdev:~$ mv metalmania.ttf /usr/local/share/fonts/truetype/ttf-metalmania/

Hint (2): Remember to verify Font's permissions on disk (777); if you save your fonts in /usr/local/share/fonts:
ximena@xdev:~$ chmod -R 777 /usr/local/share/fonts

Hint (3): The Fonts Paths can be customized in the fontconfig configuration file: /etc/fonts/fonts.conf. You can also include subdirectories or links, which is useful if you have a directory of fonts on a separate hard drive (or partition or other location).

5. Rebuild the Fonts cache:
ximena@xdev:~$ fc-cache -fv
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
/usr/local/share/fonts/truetype: caching, new cache contents: 0 fonts, 2 dirs
/usr/local/share/fonts/truetype/ttf-metalmania: caching, new cache contents: 1 fonts, 0 dirs
/usr/local/share/fonts/truetype/ttf-dejavu: caching, new cache contents: 6 fonts, 0 dirs
fc-cache: succeeded
ximena@xdev:~$

6. List the installed Fonts:
ximena@xdev:~$ fc-list

Hint (4): You may find the following useful to change default font rendering:
ximena@xdev:~$ dpkg-reconfigure fontconfig-config
ximena@xdev:~$ dpkg-reconfigure fontconfig