Fonts & Character SetsUsing custom (ttf) font in pdflatex - change search path?

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
MadEgg
Posts: 5
Joined: Wed Feb 04, 2009 4:13 pm

Using custom (ttf) font in pdflatex - change search path?

Post by MadEgg »

Hi all!

Because of requirements on my thesis which I'm writing using LaTeX (pdflatex from texlive-latex-base on Ubuntu 11.10), I have to use a specific font, namely, Georgia. Since this is a MS TrueType font, it is not available by default.

Now, I used some guides on the internet to conver the TTF files (georgia.ttf, georgiab.ttf, georgiai.ttf and georgiabi.ttf) to the correspoding AFM and TFM files. I used http://fachschaft.physik.uni-greifswald ... h/ttf.html for the general part and suggestions from http://www.radamir.com/tex/ttf-tex.htm for the slanted part.

Now, I have a set of .tfm files, a set of .afm files, a set of .ttf files, a set of .*pk files, a ttfonts.map file:

Code: Select all

georgia georgia.ttf Encoding=T1-WGL4.enc
georgiab georgiab.ttf Encoding=T1-WGL4.enc
georgiai georgiai.ttf Encoding=T1-WGL4.enc
georgiabi georgiabi.ttf Encoding=T1-WGL4.enc
georgiao georgia.ttf " .167 SlantFont T1Encoding ReEncodeFont " <T1-WGL4.enc
georgiabo georgiab.ttf " .167 SlantFont T1Encoding ReEncodeFont " <T1-WGL4.enc
and a t1georgia.fd file:

Code: Select all

\ProvidesFile{t1georgia.fd}[Georgia Font]
\DeclareFontFamily{T1}{georgia}{}
\DeclareFontShape{T1}{georgia}{m}{n}{ <-> georgia}{}
\DeclareFontShape{T1}{georgia}{m}{it}{ <-> georgiai}{}
% \DeclareFontShape{T1}{georgia}{m}{sc}{ <-> georgiac}{}
\DeclareFontShape{T1}{georgia}{m}{sl}{ <-> georgiao}{}
\DeclareFontShape{T1}{georgia}{b}{n}{ <-> georgiab}{}
\DeclareFontShape{T1}{georgia}{b}{it}{ <-> georgiabi}{}
% \DeclareFontShape{T1}{georgia}{b}{sc}{ <-> georgiabc}{}
\DeclareFontShape{T1}{georgia}{b}{sl}{ <-> georgiabo}{}

\DeclareFontShape{T1}{georgia}{bx}{n}{<-> ssub * georgia/b/n}{}
\DeclareFontShape{T1}{georgia}{bx}{it}{<-> ssub * georgia/b/it}{}
\DeclareFontShape{T1}{georgia}{bx}{sc}{<-> ssub * georgia/b/sc}{}
\DeclareFontShape{T1}{georgia}{bx}{sl}{<-> ssub * georgia/b/sl}{}
\DeclareFontShape{T1}{georgia}{l}{n}{<-> ssub * georgia/m/n}{}
\DeclareFontShape{T1}{georgia}{l}{it}{<-> ssub * georgia/m/it}{}
\DeclareFontShape{T1}{georgia}{l}{sc}{<-> ssub * georgia/m/sc}{}
\DeclareFontShape{T1}{georgia}{l}{sl}{<-> ssub * georgia/m/sl}{}

\DeclareFontShape{T1}{georgia}{m}{ui}{<-> ssub * georgia/m/it}{}
\DeclareFontShape{T1}{georgia}{b}{ui}{<-> ssub * georgia/b/it}{}
%
\endinput
As you can see, the small caps versions are still commented out because I could not find out how to create the small caps versions from the normal font. Any hints on that would be welcome, although it isn't strictly necessary right now.

To be exact: I have these files:

Code: Select all

georgia.1037pk  georgia.657pk  georgia.afm      georgiab.840pk  georgiabi.ttf    georgiai.600pk  georgiai.afm  georgiaz.afm
georgia.1200pk  georgia.720pk  georgiab.1037pk  georgiab.864pk  georgiab.tfm     georgiai.720pk  georgiai.tfm  georgiabi.tfm   
georgia.1440pk  georgia.840pk  georgiab.1493pk  georgiab.afm    georgiab.ttf     georgiai.840pk  georgiai.ttf  t1georgia.fd
georgia.1493pk  georgia.864pk  georgiab.657pk   georgiabi.afm   georgiai.1200pk  georgiai.864pk  georgia.tfm   ttfonts.map
georgia.600pk   georgia.960pk  georgiab.720pk   georgiai.1440pk  georgiai.960pk  georgia.ttf
If I put ALL these files in the same directory as my .tex file, it works and the font is nicely displayed. The thing is, I would love to have it in a seperate directory, such as fonts/georgia. I can change the font definition in my .tex file to fonts/georia/georgiab for example, but then it will complain about not being able to find the *.tfm files. I tried adding TFMFONTS=fonts/georgia to the environment. Then it does seem to be able to find the TFM files, but it complains about the .map file not being available, and besides, it will start to generate PK files for a lot of standard LaTeX fonts.

The only way I have been succesful so far is to install the files into ~/.texmf-var/fonts, but I would like my LaTeX file to compile without installing any fonts system-wide or in the user account. Also, even in that case, the t1georgia.fd file still needs to be in the same directory as the .tex file (although that is not the biggest issue, it still isn't tidy).

What I would like to do is to have the metric and truetype files of the font and t1georgia.fd in e.g. fonts/georgia, and have the *pk files automatically generated in some default location, such as ~/.texmf-var/fonts/pk, whenever required, so I do not have to copy the *pk files around between my different machines.

It seems there is such a 'nice' search path tool in use, kpathsea, but I could not find any way to tell it where to look for additional fonts without throwing the existing font database away, and while remaining portable between different platforms (esp. Mac OS X and Ubuntu, as both have the user specific texmf-var directory in a different location: ~/.texmf-var and ~/.texlive2011/texmf-var/).

Can anyone point me in the right direction? Thanks a lot in advance! If any additional information is required, let me know!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply