Fonts

Windows Fonts on Linux

The fonts in Linux are pretty good these days, with plenty of scope for adding more fonts than is probably sensible. Load up a package manger GUI and search for fonts, you'll see what I mean...

However, it's feasible that one day you'll need Window fonts for the purposes of compatibility. I've written a script below to add Windows fonts to Linux. I've tested this on Fedora 11, though hopefully it will work on Debian too. Let me know if you have any comments or improvements.

#!/bin/sh

# Note: the script must be made executable using:
# chmod +x font_install.sh

# Based on instructions from: http://www.oooninja.com/2008/01/calibri-linux-vista-fonts-download.html
# Method 2: cabextract (Linux only)
# 1. Install cabextract. On Fedora, simply run this command: sudo yum -y install
# cabextract On Ubuntu run: sudo apt-get install cabextract
# 2. Download PowerPoint Viewer 2007.
# 3. Extract the .exe: cabextract -F ppviewer.cab PowerPointViewer.exe
# 4. Prepare a separate target installation directory: sudo mkdir /usr/share/fonts/vista
# 5. Extract the actual fonts: sudo cabextract -F '*.TT?' -d /usr/share/fonts/vista ppviewer.cab
#Tip: You may substitute ~/.fonts instead of /usr/share/fonts for local, single-user installation
#which does not require root access.
# 6. Update the cache: fc-cache -fv

# SCRIPT STARTS

# Uncomment one of the following lines to install cabextract, depending on your Linux distro

# For Debian based versions of Linux (e.g. Ubuntu):
# sudo apt-get install cabextract

# For Redhat based versions of Linux (e.g. Fedora):
# sudo yum install cabextract

# sudo needs to be setup specifically on Fedora, so if this has not been done, you can use:
# su -c "yum install cabextract"

# Create a temporary folder
mkdir ~/fonts_temp_folder

# Make .fonts folder - comment line out if using global font install (see below)
mkdir ~/.fonts

# Change to that folder
cd ~/fonts_temp_folder

# VISTA FONTS FROM POWERPOINT VIEWER 2007
# Download PowerPointViewer.exe using wget
wget http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe

# MSCOREFONTS
# See: http://sourceforge.net/projects/corefonts/
# Define a variable to hold the mirror location so that this can be changed if required
MIRROR="kent.dl"

# Download the files using wget
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/andale32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/arial32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/arialb32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/comic32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/courie32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/georgi32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/impact32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/times32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/trebuc32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/verdan32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/wd97vwr32.exe
wget http://$MIRROR.sourceforge.net/sourceforge/corefonts/webdin32.exe

# Extract ppviewer.cab from the PowerPointViewer.exe file
cabextract -F ppviewer.cab PowerPointViewer.exe

# Extract .ttf font files from the ppviewer.cab file
cabextract -F '*.TT?' ppviewer.cab

# # Extract Viewer1.cab from the wd97vwr32.exe file
cabextract -F Viewer1.cab wd97vwr32.exe

# Extract tahoma.ttf font file from the Viewer1.cab file
cabextract -F 'tahoma.ttf' Viewer1.cab

# Extract the other TTF files from the remaining font .exe files
cabextract -F '*.TT?' andale32.exe
cabextract -F '*.TT?' arial32.exe
cabextract -F '*.TT?' arialb32.exe
cabextract -F '*.TT?' comic32.exe
cabextract -F '*.TT?' courie32.exe
cabextract -F '*.TT?' georgi32.exe
cabextract -F '*.TT?' impact32.exe
cabextract -F '*.TT?' times32.exe
cabextract -F '*.TT?' trebuc32.exe
cabextract -F '*.TT?' verdan32.exe
cabextract -F '*.TT?' webdin32.exe

# Choose a single user font install...
cp *.tt? ~/.fonts
cp *.TT? ~/.fonts

# Set file permissions to 755
# read = 4, write = 2, execute = 1
# 644 is equivelant to owner can read / write / execute, group can read / execute, others can read / execute
# -R means set permissions recursively (i.e. for all files / folders under target folder)
# Comment out the line below if you are doing the global font install
chmod -R 755 ~/.fonts

# Set owner to current username
# -R means set permissions recursively (i.e. for all files / folders under target folder)
# Comment out the line below if you are doing the global font install
chown -R $USERNAME ~/.fonts

# ...Or a global install (needs sudo rights)
# sudo mkdir /usr/share/fonts/microsoft
# sudo cp *.tt? /usr/share/fonts/microsoft
# sudo cp *.TT? /usr/share/fonts/microsoft

# Remove temporary folder
rm -R -f ~/fonts_temp_folder

# Recreate the font cache
fc-cache -fv

# If using the global install, comment above line and use following instead...
# sudo fc-cache -fv