![]() | ![]() | ![]() | 10 Using Truetype fonts |
To make PDF presentations that are as "fancy" as the PowerPoint presentations of competing speakers one needs to use fancy fonts. It's not hard to find nice fonts, but they are mostly in Truetype (TTF) format. This section explains how to use TTF fonts in Ipe.
Ipe relies on Pdflatex to translate the text source representation into a string of PDF operators and font subsets, that can then be used to generate Postscript, PDF, and to display the text on the screen. Ipe can therefore use any font that Pdflatex can handle, and to use a TTF font we just have to add it to Pdflatex's font reportoire.
Note that there is an alternative route for making documents using
Truetype fonts: You could convert the TTF font to Postscript Type 1
format, using the tool ttf2pfb
. The font conversion process
converts the font outlines flawlessly, as TTF's quadratic Bézier
splines can be converted exactly into Postscript cubic Bézier
splines. Postscript and Truetype fonts use different hinting systems,
though, and so hinting is not converted. This is fine as long as you
plan to print the resulting document (printer resolutions are so good
that hinting is irrelevant). But when the document is displayed on a
screen in, say, Acrobat Reader, using the original TTF font seems to
give a better result. For more information about Pdftex font handling,
see the links on the TUG pdftex support page.8
I'll explain the necessary steps for adding a TTF font using the Lucida-Handwriting font lhandw.ttf as an example (one can find this font on most PCs), giving details for teTeX (which is the TeX installation on many Unixes) and for MikTeX (which is the recommended TeX installation for Ipe on Windows).
I assume that whoever installed Ipe on your system already checked that the Pdflatex installation is not too old. Ipe requires Pdflatex 0.14f or higher, which has all the necessary TTF support. To be on the safe side, let's check the version of Pdflatex again:
mihoen[~/TtfForPdflatex].. pdflatex This is pdfTeX, Version 3.14159-13d (Web2C 7.3.1) **Oops, this is a very old version: 0.13d. You'll have to install a newer version of Pdftex.9
We will need to modify the Pdftex configuration file.
kpsewhich
can tell us where it is:
mihoen[~/TtfForPdflatex].. kpsewhich -progname=pdftex pdftex.cfg /usr/share/texmf/pdftex/config/pdftex.cfgOn MikTeX, we use
initexmf
instead of kpsewhich
:
> initexmf --find-pdflatex-input pdftex.cfg c:\texmf\pdftex\config\pdftex.cfg
My original configuration contained a single fontmap line (map
pdftex.map
). We copy the file into the current directory, and try
again:
mihoen[~/TtfForPdflatex].. cp /usr/share/texmf/pdftex/config/pdftex.cfg . mihoen[~/TtfForPdflatex].. kpsewhich -progname=pdftex pdftex.cfg ./pdftex.cfg
So now we have a personal copy of the configuration file. Add the following line:
map +myfonts.mapand create a file myfonts.map in the current directory:
lhandw <lhandw.ttf <T1-WGL4.encWe check that it is found:
mihoen[~/TtfForPdflatex].. kpsewhich -progname=pdftex myfonts.map ./myfonts.mapOn MikTeX:
> initexmf --find-pdflatex-input myfonts.map myfonts.map
Now we have to create a TFM file (Tex metric file) for the font. I
use ttf2tfm
for this. A recent version is included in the
binary distribution of Ipe for Windows. You can probably find an rpm
package that installs it on Linux, such as Suse's
freetype-tools.rpm
. I simply built a Unix version from
sources.10
We also copy the file T1-WGL4.enc into the current directory.
mihoen[~/TtfForPdflatex].. ttf2tfm lhandw.ttf -p T1-WGL4.enc <...lots of output, listing all the characters, and complaining about characters that haven't been found ...> Using T1-WGL4.enc as input encoding. lhandw lhandw.ttf Encoding=T1-WGL4.enc(There are also several messages about missing glyphs.) The last line output is meant to be put into the fontmap file. I'm not sure whether Pdflatex can handle this syntax -- the one I've shown above works in any case.
For the moment, we'll just leave the resulting file lhandw.tfm in the current directory. Check that Pdflatex will find it there:
mihoen[~/TtfForPdflatex].. kpsewhich -progname=pdftex lhandw.tfm ./lhandw.tfm
Now we need to ask Pdflatex to use the new font. Here is a little test file test.tex.
% File 'test.tex' \documentclass{article} \renewcommand{\encodingdefault}{T1} \renewcommand{\rmdefault}{lhandw} \renewcommand{\sfdefault}{phv} \renewcommand{\ttdefault}{pcr} \title{Using Lucida Handwriting} \author{Otfried Cheong} \begin{document} \maketitle This is just a silly test of the Lucida-Handwriting font. \end{document}
This makes Lucida-Handwriting the default roman font (and uses Helvetica and Courier as sans-serif and typewriter fonts).
Running Pdflatex on test.tex succeeds, but shows this message:
LaTeX Font Warning: Font shape `T1/lhandw/m/n' undefined (Font) using `T1/cmr/m/n' instead on input line 8. [1{/usr/share/texmf/dvips/config/pdftex.map}{myfonts.map}] (./test.aux)Pdflatex correctly reads my myfonts.map file, but still doesn't know about the font. What is missing is a font description file. Latex is looking for the font "T1/lhandw/m/n", so this file has to be called t1lhandw.fd. I've created such a file in the current directory:
\ProvidesFile{t1lhandw.fd}[Lucida-Handwriting font] \DeclareFontFamily{T1}{lhandw}{} \DeclareFontShape{T1}{lhandw}{m}{n}{ <-> lhandw }{} \DeclareFontShape{T1}{lhandw}{bx}{n}{<->ssub * lhandw/m/n}{} \DeclareFontShape{T1}{lhandw}{m}{it}{<->ssub * ptm/m/it}{} \DeclareFontShape{T1}{lhandw}{m}{sl}{<->ssub * ptm/m/sl}{} \DeclareFontShape{T1}{lhandw}{m}{sc}{<->ssub * ptm/m/sc}{} \DeclareFontShape{T1}{lhandw}{bx}{it}{<->ssub * ptm/b/it}{} \DeclareFontShape{T1}{lhandw}{bx}{sl}{<->ssub * ptm/b/sl}{} \DeclareFontShape{T1}{lhandw}{bx}{sc}{<->ssub * ptm/b/sc}{}
We tell Pdflatex to use the Lucida font for both the normal medium and the bold style. The remaining six declarations tell Pdflatex to substiture the Times font for the italic, slanted, and small-caps shapes of the roman font.
Running pdflatex again shows this message:
(/usr/share/texmf/tex/latex/base/size10.clo)) (./test.aux) (./t1lhandw.fd) [1{/usr/share/texmf/dvips/config/pdftex.map}{myfonts.map}] (./test.aux) ){T1-WG L4.enc}<lhandw.ttf>This worked, and the resulting PDF file looks fine in both Xpdf and Acrobat Reader.
By now we have cluttered up the current directory with lots of new files: pdftex.cfg, myfonts.map, t1lhandw.fd, T1-WGL4.enc, lhandw.ttf , and lhandw.tfm. All of these should go into a nice cosy place on the system, so that they can actually be found when Pdflatex is run from within Ipe.
If you are not a system administrator on a Unix system, you would just create your own small TeX-tree, and set the environment variables TEXPSHEADERS (for .map and .enc files), TTFONTS for Truetype fonts, and TEXINPUTS for pdftex.cfg and .fd files.
If you are a system administrator, you should move the files to suitable places in the local TeX-tree.
On MikTeX, I recommend creating a local TeX-tree as well. Create a
directory, say c:\Mytexmf
and start the MikTeX options
program (in the MikTeX menu). In the "Roots" tab, press "Add" and
select the directory you just created. Move it up so that it is
before the standard root directory (c:\texmf
). You can now
check the configuration file \texmf\miktex\config\miktex.ini
for the exact paths searched by MikTeX. One choice would be
It should now work to compile test.tex even when that is the only file in the current directory.
Finally, we are ready to try the font from within Ipe. Let's first
assume you only want to use the new font in a few places in your Ipe
document. You should define a command analogous to \textrm
to
switch to the new font. Open the Document properties dialog in
the Edit menu, and add this line to the Latex preamble:
\DeclareTextFontCommand{\textlh}{\fontencoding{T1}\fontfamily{lhandw}\selectfont}You can now use
\textlh
insider Ipe text objects to typeset in
Lucida-Handwriting.
Finally, let's make a multi-page presentation typeset wholly using Lucida-Handwriting. This declaration in the Latex preamble will change the document fonts:
\renewcommand{\encodingdefault}{T1} \renewcommand{\rmdefault}{lhandw} \renewcommand{\sfdefault}{phv} \renewcommand{\ttdefault}{pcr}Note that this switches all text fonts to TTF or Postscript fonts. This is necessary, as we use the
T1
encoding (an 8-bit
encoding) for Lucida-Handwriting. Keeping Computer-Modern as the font
for \textsf
or \texttt
would cause LaTeX to load the
T1
version of Computer-Modern. These are bitmapped "Type3"
fonts, which Ipe cannot handle.
![]() | ![]() | ![]() | 10 Using Truetype fonts |