How do I use TrueType fonts with LaTeX
I need to use a font family in my LaTeX documents, that is available as 18 .TTF (TrueTypeFont) files.
Where do I have to copy the files in my MiKTeX开发者_如何学运维 2.8 installation? How Do I make the fonts available for LaTeX?
I usually use pdfLaTeX. I read in Truetype-Fonts in LaTeX that TTF fonts are available without creating all the .TFM files. What is necessary for this case?
Can I install the fonts in the local-texfm directory? I would like to isolate the system installation and my manually added stuff. Probably it would be easier to copy this font family on another installation.
The easiest way would be to use XeLaTeX, for which you would just install the fonts to your system. A basic template would look like this (from https://web.archive.org/web/20111115151939/http://theotex.blogspot.com/2008/04/what-is-xetex-basic-template_15.html) :
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[10pt]{memoir}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Numbers=Uppercase]{Hoefler Text}
\setmonofont[Scale=0.90,Ligatures=NoCommon]{Courier}
\title{Your Title}
\author{Your Name}
\date{}
\begin{document}
\maketitle
\chapter{Title}
\section{Section Title}
Your text
\subsection{Subsection Title}
Your Text
\end{document}
If you want to stick to LaTeX, you can generally try these steps:
- Create the TeX font metrics (tfm), the font description (fd) and the font mapping (map).
- Using
ttf2tfm
to generate.vpl
, thenvptovf
to create.tfm
.
- Using
- Put the files (ttf, tfm, fd, map) into the proper directories in the local texmf tree.
- Update the TeX filename database.
- Using
texhash
- Using
- Register the mapping.
- Using
updmap-sys
- Using
It seems rather straightforward, but there are many traps regarding the font description and mapping, as well as the naming scheme for the output files.
There are a lot of scripts and howtos which didn't work for me. So I wrote this tool to help me use ttf fonts with LaTeX: http://devnotcorp.wordpress.com/2011/06/10/use-truetype-font-with-pdflatex/.
Although it's many years later I thought of adding that if one uses LuaLaTeX, you don't need to do anything apart from using the LuaLaTex package fontspec and then in the preamble of in the document \setmainfont{ComicSansMS}.
Use ttf2tfm
and ttf2pk
programs
try the following: http://www.radamir.com/tex/ttf-tex.htm. I tried it several YEARS ago; i found some bugs but I can't remember them anymore. I think it had something to do with wrong files being used with another program. The author had SWITCHED file extensions due to confusion because of the number of files being generated. I notified the author about it but I don't know if he had corrected it.
精彩评论