Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

One of the annoying aspects of LaTeX is the limited number of fonts that come by default, and the pain involved in making new fonts 'LaTeX' ready. I have a collection of truetype fonts that I'd like to prepare for use, and I definitely want to make sure I have vector versions of these fonts (i.e not type 3/bitmapped versions). Is there a relatively painless way to do this ?

share|improve this question
    
Short answer: not really. I had to do it once 6 years ago to get some additional Chinese fonts working with CJKlatex, and all I can remember of that experience is that it was a complete pain and I would never, ever try to do that again. –  Willie Wong Jul 27 '10 at 1:39
5  
@Willie: This is an example of the all-too-common XY problem: the answer to "is there a painless way to generate latex font metrics from TTF fonts?" may well be "not really", but the XeLaTeX mention below is an answer to the question of "is there a painless way of using TTF fonts in a document?". :-) –  ShreevatsaR Jul 27 '10 at 4:12
    
@ShreevatsaR: you are absolutely right. I didn't even consider the second option as being the question that was asked. My bad. –  Willie Wong Jul 27 '10 at 5:03
    
@ShreevatsaR: exactly. It's not obvious from the question whether latex engine is a must, or any engine capable of processing LaTeX syntax is fit for the answer. Also it hasn't been specified which type of output is expected: dvi, ps, pdf, svg, or all of the above. –  Dima Jul 27 '10 at 12:38
4  
There is a nice TUGboat article by S. Kroonenberg called "Font installation the shallow way" <tug.org/TUGboat/Articles/tb27-1/tb86kroonenberg-fonts.pdf>;. The article provides a number of examples of how to use different kinds of fonts with (pdf)LaTeX. –  Martin Heller Aug 10 '10 at 18:26
show 4 more comments

5 Answers

up vote 20 down vote accepted

One solution is to use XeLaTeX, which lets you use system fonts (mostly) hassle-free.

share|improve this answer
    
does that work in linux, and how does it help with installing fonts ? –  Suresh Jul 27 '10 at 0:48
2  
XeLaTeX works on linux (and is probably installed already). It's a separate TeX engine, produces PDFs, and can use truetype fonts directly. –  ShreevatsaR Jul 27 '10 at 1:38
    
I helps with installaing fonts, since nothing special needs to be done at all to use an already available system ttf font. –  Dima Jul 27 '10 at 1:54
3  
That is the only viable solution now. It's 2011, we have XeLaTeX and LuaLaTeX, and they work. So use them. –  Martin Schröder Aug 24 '11 at 10:07
add comment

Prepare for the world of pain.

See the same question I posted on superuser

share|improve this answer
    
Actually I think it might make more sense to duplicate the relevant information from SU here, since this site is supposed to become the LaTeX reference. –  David Z Jul 27 '10 at 1:40
    
Except that there's no relevant information on SU, beyond "I couldn't get it to work". :-) –  ShreevatsaR Jul 27 '10 at 1:48
1  
Fair enough =) If anyone can point me to a recent guide on generating latex font metrics along with raster font for latex and ``fake" ttf fontmap for pdflatex I would highly appreciate it. –  Dima Jul 27 '10 at 1:53
    
@Dima If you insist on using a format that was created by a professor in Stanford for use in his books more than 30 years ago, you are asking for pain. The rest of the world simply uses ConTeXt or XeLaTeX/LuaLaTeX, where this just works. –  Martin Schröder Aug 24 '11 at 10:11
add comment

LuaTeX brings TTF-support, but I have no Idea how mature it is right now.

share|improve this answer
    
It works. And it's not too difficult to use in ConTeXt. But I'm not sure if anyone exposed this functionality to LaTeX already. –  Roman Plášil Aug 9 '10 at 7:17
2  
The above example for xelatex (with fontspec + Arial) will work unchanged with lualatex too (with a recent fontspec). A discussion about difference of xelatex + lualatex is here tex.stackexchange.com/questions/3094/drawbacks-of-xetex-luatex –  Ulrike Fischer Oct 20 '10 at 7:45
add comment

The process for PdfTeX is something like this (depends a little bit on your distribution):

  1. Get autoinst.pl from Fontools from CPAN
  2. Get otf2tfm from lcdf-typetools
  3. Run autoinst.pl (using Perl) on all ttfs
  4. Add generated PdfTeX font mapping (in MikTeX for instance initexmf --edit-config-file updmap, add Map yourmap.map and run initexmf --mkmaps)

You can do the whole process manually as well (autoinst.pl is nothing but a smart wrapper):

  1. Create tfm metrics and a ttfonts.map using ttf2tfm
  2. Create virtual font tables using vptovf
  3. Create afm metrics using ttf2afm
  4. Create pdf font map using afm2tfm
  5. Put *.tfm, *.afm, *.ttf, *.vf into the fonts/tfm/ etc.
  6. Add the font maps
  7. Create a package/sty to pull the various fonts into a font family (this is where I am stuck)

My ruby script for running the commands looks like this:

require 'fileutils'  

basename = "Nexus"

open("#{basename}.map", 'a') { |pdfFontMap|

    Dir["#{basename}*.ttf"].each{ |file|

        file.sub!(/\.ttf$/, "")

        ttf = "#{file}.ttf"

        file.gsub!(/_/,"") # Remove underscores

        puts `ttf2tfm #{ttf} -q -T T1-WGL4.enc -v ec#{file}.vpl rec#{file}.tfm >> ttfonts.map`

        puts `vptovf ec#{file}.vpl ec#{file}.vf rec#{file}.tfm`

        puts `ttf2afm -e T1-WGL4.enc -o rec#{file}.afm #{ttf}`

        pdfFontMap.puts `afm2tfm rec#{file}.afm -T T1-WGL4.enc rec#{file}.tfm`.gsub(/\r|\n/, "") + " <#{ttf}"
    }
}

You can find more details about the manual way in:

http://www.radamir.com/tex/ttf-tex.htm

P.S.:

  • Run initexmf --update-fndb EVERY time new files are put somewhere
share|improve this answer
add comment

The easiest way is with XeTeX or LuaTeX and the fontspec package. They can use any TTF font installed on the system. For Linux this means both the system wide fonts and any fonts you put into ~/.fonts/ (e.g. by installing them via Nautilus).

To use the fonts you simply have to load the fontspec package and set the font:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Arial}

\begin{document}
Lorem ipsum...
\end{document}

Then compile the the document with xelatex or lualatex. The fontspec documentation describes all the possibilities for changing fonts.

The only drawbacks (as far as I am aware) are that you can only generate .pdf files and that you need a sufficiently new TeX distribution (TeX Live 2009 should work for XeTeX and Tex Live 2010 for LuaTeX).

share|improve this answer
    
I use XeTeX myself and think it's a good solution. There are some drawbacks, though, that may or may not be important to particular users. One of the major drawbacks for some is that the microtype package for XeTeX is not fully functional; microtype with pdftex gives much better results. –  Herbert Sitz Aug 22 '10 at 5:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.