Thursday, September 23, 2010

OpenOffice and Windows PowerPoint PPT/PPTX files in Ubuntu 10.04

One of the recent issues I encountered was opening PowerPoint documents in OpenOffice. I noticed font-rendering issues. It made me realize that the Ubuntu 10.04 install doesn't come with the Vista/Windows 7 fonts.

I followed these instructions:
http://embraceubuntu.com/2007/09/16/installing-vista-fonts-in-ubuntu/

sudo apt-get install cabextract
sudo apt-get install curl
sudo apt-get install wget
I then downloaded this installer script:
wget http://plasmasturm.org/code/vistafonts-installer/vistafonts-installer
The installer script will download the Microsoft PowerPoint Viewer (25MB fil) and extract the various fonts (Calibri, Cambria, Candara, etc.).
mkdir ~/.fonts
chmod a+x ~/vista-fonts-installer
to make the file/script executable.
Then run the script using:
$ ./vista-fonts-installer

Notice inside the vista-fonts-installer.sh, there is this line:
fc-cache -fv ~/.fonts
The installer script wants you to download your fonts into ~/.fonts. If you intend to share the instance with multiple users, it may be better to move them into /usr/share/fonts/vista or /usr/share/fonts/windows7. You should run "fc-cache -fv /usr/share/fonts/[dir]" if you move your font files.

My script therefore got changed to:

#!/bin/sh
# Copyright (c) 2007 Aristotle Pagaltzis
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

set -e

exists() { which "$1" &> /dev/null ; }

if ! [ -d /usr/share/fonts/windows7 ] ; then
 exec 2>&1
 echo 'There is no .fonts directory in your home.'
 echo 'Is fontconfig set up for privately installed fonts?'
 exit 1
fi

# split up to keep the download command short
DL_HOST=download.microsoft.com
DL_PATH=download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26
ARCHIVE=PowerPointViewer.exe
URL="http://$DL_HOST/$DL_PATH/$ARCHIVE"


if ! [ -e "$ARCHIVE" ] ; then
 if   exists curl  ; then curl -O "$URL"
 elif exists wget  ; then wget    "$URL"
 elif exists fetch ; then fetch   "$URL"
 fi
fi

TMPDIR=`mktemp -d`
trap 'rm -rf "$TMPDIR"' EXIT INT QUIT TERM

cabextract -L -F ppviewer.cab -d "$TMPDIR" "$ARCHIVE"

cabextract -L -F '*.TT[FC]' -d /usr/share/fonts/windows7 "$TMPDIR/ppviewer.cab"

( cd /usr/share/fonts/windows7 && mv cambria.ttc cambria.ttf && chmod 644 \
 calibri{,b,i,z}.ttf cambria{,b,i,z}.ttf candara{,b,i,z}.ttf \
 consola{,b,i,z}.ttf constan{,b,i,z}.ttf corbel{,b,i,z}.ttf )

fc-cache -fv /usr/share/fonts/windows7


The other thing you may need to do is logout and log back in. This will let you insure that the fonts are loaded properly.

1 comment: