<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>∃xistential Type &#187; pdftex</title>
	<atom:link href="http://existentialtype.net/tag/pdftex/feed/" rel="self" type="application/rss+xml" />
	<link>http://existentialtype.net</link>
	<description>For People Who Like Type and Types</description>
	<lastBuildDate>Mon, 24 Aug 2009 18:53:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Fonts in LaTeX, Part Three: pdfTeX and TrueType</title>
		<link>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/</link>
		<comments>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 16:13:22 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
				<category><![CDATA[typography]]></category>
		<category><![CDATA[deja vu sans]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[pdflatex]]></category>
		<category><![CDATA[pdftex]]></category>
		<category><![CDATA[tex]]></category>
		<category><![CDATA[tex gyre pagella]]></category>
		<category><![CDATA[truetype]]></category>
		<category><![CDATA[ttf2tfm]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=259</guid>
		<description><![CDATA[Update: The information in this post is out of date: otftotfm does presently have support for TrueType outlines. See my errata post for more information. In the previous part of this tutorial, I explained how to put together the minimal infrastructure needed to use an OpenType font with pdfLaTeX.  However, I used the tool otftotfm [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: The information in this post is out of date: <code>otftotfm</code> does presently have support for TrueType outlines.  See my <a href="http://existentialtype.net/2009/04/04/fonts-in-latex-errata/">errata post</a> for more information.</p>
<p>In the <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/">previous part of this tutorial</a>, I explained how to put together the minimal infrastructure needed to use an <a href="http://en.wikipedia.org/wiki/OpenType">OpenType</a> font with pdfLaTeX.  However, I used the tool <code>otftotfm</code> to generate the font metrics TeX needs to lay out text. However, <code>otftotfm</code> only supports OpenType fonts that use PostScript font outlines, as opposed to <a href="http://en.wikipedia.org/wiki/TrueType">TrueType</a> font outlines. So in this part of the tutorial I will explain how to put together the necessary infrastructure for TrueType fonts. In preparation for that, we will first make a few changes to what we had done earlier.</p>
<p>For those that would find it useful, I've put together a  <a href="http://existentialtype.net/wp-content/uploads/2008/07/fonts-tutorial.zip">zip file</a> containing all the files from the tutorials (except the fonts, which I don't want to deal with distributing).</p>
<p>Firstly, we are going to move the uses of <code>\DeclareUnicodeCharacter</code> out of <code>UPagella.fd</code> and into <code>uenc.def</code>:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">uenc.def</span>}
<span style="color: #808080; font-style: italic;">% We are declaring an encoding named &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontEncoding</span>{<span style="color: #2222D0; font-weight: normal;">U}{}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Technically these are not &quot;allowed&quot; in .def files,</span>
<span style="color: #808080; font-style: italic;">% but this is really the logical place to put the</span>
<span style="color: #808080; font-style: italic;">% declarations.</span>
&nbsp;
<span style="color: #808080; font-style: italic;">% τ (0x03C4) maps to 0xF8 in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C4}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F8</span>}
<span style="color: #808080; font-style: italic;">% ε (0x03B5) maps to 0xF9 in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03B5}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F9</span>}
<span style="color: #808080; font-style: italic;">% χ (0x03C7) maps to 0xFA in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C7}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;FA</span>}</pre>
<p>As I mention in the comments, the documentation on font encoding definition files does not list <code>\DeclareUnicodeCharacter</code> to be one of the allowed declarations in a such a file, but it works, and it seems like the more logical place to configure it than in the font definition file.</p>
<p>Now that we have removed the uses of <code>\DeclareUnicodeCharacter</code> from <code>UPagella.fd</code>, it looks like:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">UPagella.fd</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Delcaring a font family called &quot;Pagella&quot; for the encoding &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Declare that font family &quot;Pagella&quot;, for encoding &quot;U&quot;, has a shape</span>
<span style="color: #808080; font-style: italic;">% with weight medium (m) and normal (n) slant (in otherwords, upright)</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{m}{n</span>}{
  <span style="color: #808080; font-style: italic;">% For all sizes...</span>
  &amp;lt;-&amp;gt;
  <span style="color: #808080; font-style: italic;">% ... use the font named</span>
  TeXGyrePagella-Regular--custom--base
}{}</pre>
<p>I am going to use <a href="http://dejavu.sourceforge.net/wiki/index.php/Download">Deja Vu Sans</a> as the example TrueType font.  Fortunately, if you followed everything from the second part of the tutorial, there is not much that needs to be done.</p>
<p>First, we need to generate metrics for Deja Vu Sans.  As before, if you are using <a href="http://www.tug.org/texlive/">TeX Live</a>, you'll have the necessary program:</p>
<pre>
% ttf2tfm DejaVuSans.ttf -q -T custom
ttf2tfm: WARNING: Cannot find character `compwordmark'
         specified in input encoding.
...
...
ttf2tfm: WARNING: Cannot find character `zdotaccent'
         specified in input encoding.
DejaVuSans   DejaVuSans.ttf Encoding=custom.enc</pre>
<p>The program <code>ttf2tfm</code> is kind of unusual in that it first takes the filename argument and then all the options.  So we've passed it the TrueType font we want to generate metrics for, <code>DejaVuSans.ttf</code>, the option <code>-q</code> to tell it not to print quite so much information, and the option <code>-T custom</code> which tells it to use the encoding defined in the file <code>custom.enc</code> we created in previous part.</p>
<p>Unlike <code>otftotfm</code>, <code>ttf2tfm</code> does not generate an entry that we could use in our <code>map</code> file, <code>custom.map</code>, so we need to write one ourselves.  You will want to start with the <code>map</code> we generated by <code>otftotfm</code> for Tex Gyre Pagella, and you will want to add the line:</p>
<pre>DejaVuSans &lt;custom.enc &lt;DejaVuSans.ttf</pre>
<p>This says to map the TeX font name <code>DejaVuSans</code> to the file <code>DejaVuSans.ttf</code> using the encoding <code>custom.enc</code>.  To learn more about the format of <code>map</code> files, there is a section on them in the <a href="http://sarovar.org/docman/view.php/106/66/pdftex-s.pdf">pdfTeX manual</a>.</p>
<p>Now we just need to create a font definition file for Deja Vu Sans.  However, it is essentially the same as the one we created for TeX Gyre Pagella:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">UDejaVuSans.fd</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Delcaring a font family called &quot;DejaVuSans&quot; for the encoding &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{DejaVuSans}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Declare that font family &quot;DejaVuSans&quot;, for encoding &quot;U&quot;, has a shape</span>
<span style="color: #808080; font-style: italic;">% with weight medium (m) and normal (n) slant (in otherwords, upright)</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{DejaVuSans}{m}{n</span>}{
  <span style="color: #808080; font-style: italic;">% For all sizes...</span>
  &amp;lt;-&amp;gt;
  <span style="color: #808080; font-style: italic;">% ... use the font named</span>
  DejaVuSans
}{}</pre>
<p>We have just replaced all occurrences of <code>Pagella</code> with <code>DejaVuSans</code>.</p>
<p>Finally, we just need to update our example document to use Deja Vu Sans:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\documentclass</span>{<span style="color: #2222D0; font-weight: normal;">article</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">utf8</span>]{<span style="color: #2222D0; font-weight: normal;">inputenc</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">U</span>]{<span style="color: #2222D0; font-weight: normal;">fontenc</span>}
<span style="color: #800000; font-weight: normal;">\pdfmapfile</span>{<span style="color: #2222D0; font-weight: normal;">+custom.map</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\rmdefault</span>}{Pagella</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\sfdefault</span>}{DejaVuSans</span>} 
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">sffamily</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">sffamily</span>}
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}</pre>
<p>Here we have used <code>\renewcommand</code> to set the default sans serif font, <code>\sfdefault</code>, to be <code>DejaVuSans</code>.  In the body of the document, we've copied the text and surrounded it with the <code>sffamily</code> environment to have it typeset in sans serif.</p>
<p>Now we have everything we need to run <code>pdflatex</code>:</p>
<pre>
% pdflatex test-pdflatex.tex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&amp;-line parsing enabled.
...
...
(./test-pdflatex.aux) (./upagella.fd) (./udejavusans.fd) [1]
(./test-pdflatex.aux) ){custom.enc}{a_qnnnfc.enc}&lt;./TeXGyrePage
lla-Regular.pfb&gt;
Output written on test-pdflatex.pdf (1 page, 34857 bytes).
Transcript written on test-pdflatex.log.</pre>
<p>And we have the desired output:</p>
<div style="text-align: center"><a href="http://existentialtype.net/wp-content/uploads/2008/07/test-pdflatex.png"><img class="aligncenter size-full wp-image-260" title="test-pdflatex" src="http://existentialtype.net/wp-content/uploads/2008/07/test-pdflatex.png" alt="Testing pdfLaTeX with both OpenType and TrueType fonts" width="245" height="140" /></a></div>
<p>And that's everything you need to get started with TrueType fonts and pdfLaTeX.  Again, if you encounter any problems or notice any omissions, let me kow. I'll do some investigation and there will possibly be a fourth part on using <a href="http://www.tug.org/applications/fontinst/">fontinst</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Fonts in LaTeX, an intermission</title>
		<link>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/</link>
		<comments>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:58:01 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
				<category><![CDATA[meta]]></category>
		<category><![CDATA[typography]]></category>
		<category><![CDATA[fontinst]]></category>
		<category><![CDATA[lua]]></category>
		<category><![CDATA[luatex]]></category>
		<category><![CDATA[opentype]]></category>
		<category><![CDATA[pdftex]]></category>
		<category><![CDATA[reddit]]></category>
		<category><![CDATA[truetype]]></category>
		<category><![CDATA[xetex]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=258</guid>
		<description><![CDATA[Part one of my tutorial attracted a considerable number of visitors, far more than any single entry in the past, partly because it was posted to reddit. Looking at the comments on reddit, I figured that I would say that luatex does resolve pdfTeX's internal limitation of 256 glyphs that I mentioned in part two, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/">Part one</a> of my tutorial attracted a considerable number of visitors, far more than any single entry in the past, partly because it was posted to <a href="http://www.reddit.com/r/programming/info/6rg7f/comments/">reddit</a>.</p>
<p>Looking at the comments on reddit, I figured that I would say that <a href="http://www.luatex.org/">luatex</a> does resolve pdfTeX's internal limitation of 256 glyphs that I mentioned in <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/">part two</a>, and it should directly support OpenType fonts with PostScript outlines.</p>
<p>However, my understanding is that the authors of luatex do not intend to make using TrueType and OpenType fonts as simple as XeTeX directly.  Instead, luatex merely makes the machinery available for someone else to build upon.  So someone will need to write a LaTeX package for luatex to put it all together, and as far as I know, no one has done this yet (let me know if I'm wrong!).  Also, while the plan is for luatex to eventually be merged back into pdfTeX, I think it is an overstatement to say that it will happen "soon".  The current luatex roadmap says that a "production" ready version will be available in <a href="http://www.luatex.org/roadmap.html">August 2009</a>.  I doubt that the merge back to pdfTeX will happen any sooner than 2010 given that.  But yes, in the long term I think luatex will be a great thing.</p>
<p>It also sounds like I should probably write a fourth part to my tutorial on using <a href="http://www.tug.org/applications/fontinst/">fontinst</a>.  I've never personally used it myself, and when I first started working with OpenType fonts and LaTeX I wasn't aware of its existence.  Therefore, I wrote <a href="http://free-the-mallocs.com/otftofd">otftofd</a>.  So it might take a bit longer to write as I will have to learn it at the same time.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fonts in LaTeX, Part Two: pdfTeX and OpenType</title>
		<link>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/</link>
		<comments>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 16:02:35 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
				<category><![CDATA[typography]]></category>
		<category><![CDATA[fontinst]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[microtypography]]></category>
		<category><![CDATA[opentype]]></category>
		<category><![CDATA[otftofd]]></category>
		<category><![CDATA[otftotfm]]></category>
		<category><![CDATA[pagella]]></category>
		<category><![CDATA[pdflatex]]></category>
		<category><![CDATA[pdftex]]></category>
		<category><![CDATA[postscript]]></category>
		<category><![CDATA[tex]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=253</guid>
		<description><![CDATA[In part one of the tutorial, I commented that sometimes you would want to use pdfTeX and pdfLaTeX instead of XeTeX and XeLaTeX. One reason to consider using pdfTeX over XeTeX is that the latter does not yet support the same microtypographic features. When you are preparing slides, pdfTeX's microtypographic features probably will not have [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/">part one of the tutorial</a>, I commented that sometimes you would want to use <a href="http://www.tug.org/applications/pdftex/">pdfTeX and pdfLaTeX</a> instead of XeTeX and XeLaTeX.  One reason to consider using pdfTeX over XeTeX is that the latter does not yet support the same <a href="http://en.wikipedia.org/wiki/Microtypography">microtypographic</a> features.  When you are preparing slides, pdfTeX's microtypographic features probably will not have much of an impact on your output, but I've definitely found that while preparing articles and my dissertation, using pdfTeX's microtypographic features produces much nicer looking output with fewer bad breaks or hyphenations.</p>
<p>However, pdfTeX's architecture for handling fonts is much more like standard TeX and is <em>far</em> more complicated that XeTeX's. One option is to use a tool to do all the work for you.  For example, you could use the <a href="http://www.tug.org/applications/fontinst/">fontinst utility</a> or my own tool, <a href="http://free-the-mallocs.com/otftofd">otftofd</a>.  The other option is to do it all by hand, which is what I will explain in this tutorial.</p>
<p>One of the first complications you'll encounter with pdfTeX is that the font that is active at a given time can only refer to 256 glyphs at a time.  Therefore if you need to use more than 256 different glyphs in a document, you will need to switch between multiple "fonts".</p>
<p>The first step in using a font in pdfTeX is picking an encoding. Since most OpenType fonts contain more than 256 glyphs, an encoding provides a mapping from those glyphs to the 256 that you can reference at a given time in pdfTeX.</p>
<p>For the most part I generally just use what is called the <a href="http://en.wikipedia.org/wiki/Cork_encoding">T1 or "Cork" encoding</a>.  However, if we want to replicate the example from the first part of the tutorial, we will need to make a custom encoding to access the Greek glyphs.  So, first use <code>kpsewhich</code> to find where your system keeps <code>cork.enc</code>, and make a copy:<br />
<code><br />
% kpsewhich cork.enc<br />
/local/texlive/2007/texmf-dist/fonts/enc/dvips/base/cork.enc<br />
% cp /local/texlive/2007/texmf-dist/fonts/enc/dvips/base/cork.enc ./custom.enc<br />
</code><br />
Open <code>custom.enc</code> in you favorite editor, and go to the end. Assuming you are using the same version of TeX Live as me, the last few lines will look something like:<br />
<code><br />
/oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code><br />
You will want to edit it to look like:<br />
<code><br />
<span style="color: #ff0000;">/tau /epsilon /chi</span> /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code><br />
What we have done is changed the encoding so that glyphs 0xf8, 0xf9, 0xfa (in hexadecimal) now point to τ, ε, and χ.  The general format of entries in the encoding file is <code>/</code> followed by a name.  In the case that the software doesn't understand a name that you think it should, you can always specify the gylph using its Unicode hexadecimal name prefixed with <code>/uni</code>.  For example, we could have changed the encoding as followings:<br />
<code><br />
<span style="color: #ff0000;">/uni03c4 /uni03b5 /uni03c7</span> /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code></p>
<p>A complete list of glyph names can be obtained from <a href="http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt">Adobe's website</a>.  You can learn more about the encoding file format from the <a href="http://www.radicaleye.com/dvipsman/dvips.html#SEC62">dvips documentation</a>, though the eagle-eye may have noticed that actually a subset of <a href="http://en.wikipedia.org/wiki/PostScript">PostScript</a> itself.</p>
<p>Next, we need to create a file to tell LaTeX about our new encoding, which we will call U for "user-defined".  Create a file in the current directory called <code>uenc.def</code> and put the following in it:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">uenc.def</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontEncoding</span>{<span style="color: #2222D0; font-weight: normal;">U}{}{</span>}</pre>
<p>As it says, it is defining a new font encoding called "U".</p>
<p>Now that we have an encoding, we need to generate font metrics that pdfTeX can understand, and a mapping file to tell it how to map font names to encodings and actual font files.  Additionally, pdfTeX (at least last I checked) cannot handle OpenType fonts that contain PostScript rather than TrueType font outlines.  So we also need to convert our OpenType font, <a href="http://www.gust.org.pl/projects/e-foundry/tex-gyre/pagella">Pagella</a>, to <a href="http://en.wikipedia.org/wiki/Type_1_and_Type_3_fonts#Type_1">Type1 format</a>.  Fortunately, Eddie Kohler's excellent tool <a href="http://www.lcdf.org/type/otftotfm.1.html">otftotfm</a> will do most that for us.  Again, it is included with TeX Live.  We invoke it on the font we wish to use, with the encoding we have created, and redirect the output to a file called <code>custom.map</code>:</p>
<pre>
% otftotfm -e custom.enc texgyrepagella-regular.otf &gt; custom.map
otftotfm: ./custom.enc:19: warning: 'space' has no encoding, ignoring ligature
otftotfm: ./custom.enc:19: warning: 'space' has no encoding, ignoring ligature
otftotfm: ./custom.enc:30: warning: 'space' has no encoding, ignoring '{}'
otftotfm: ./custom.enc:30: warning: 'space' has no encoding, ignoring '{}'
I had to round some heights by 13.0000000 units.
I had to round some depths by 3.0000000 units.
I had to round some heights by 13.0000000 units.
I had to round some depths by 3.0000000 units.
</pre>
<p>Don't be concerned about the warnings.  The first few are just complaints because there is no "space" gylph, which is not used by TeX.  The rounding warnings occur, I assume, because PostScript metrics differ very slightly from TeX's internal representation of size metrics.  An <code>otftotfm</code> unit is about one thousandth of an em.</p>
<p>We now have have several new files in the current directory:</p>
<pre>
a_qnnnfc.enc
custom.map
TeXGyrePagella-Regular--custom--base.tfm
TeXGyrePagella-Regular--custom.tfm
TeXGyrePagella-Regular--custom.vf
TeXGyrePagella-Regular.pfb</pre>
<p>The <code>pfb</code> file is the PostScript Type 1 version of our original OpenType font, the file <code>custom.map</code> is used to tell pdfTeX how to map a font name to files, the two <code>tfm</code> provide the font metric information TeX needs to format text, the <code>vf</code> file is a "virtual font" file that depending on the options you gave to <code>otftotfm</code> may perform some operations on the basic glyphs, and the file <code>a_qnnnfc.enc</code> is an encoding <code>otftotfm</code> generated based upon the encoding we supplied it.  Depending on the options, <code>otftotfm</code> may try to include some additional glyphs to deal with ligatures or in the case that a glyph in the encoding we specified doesn't exist in the font, it will replace its entry with <code>/.notdef</code>, etc.</p>
<p>Next we want to take a peek inside of <code>custom.map</code>. It's contents will look something like the following:<br />
<code><br />
TeXGyrePagella-Regular--custom--base TeXGyrePagella-Regular "AutoEnc_qnnnfca3qut7llkesqq3eddyzc ReEncodeFont" &lt;[a_qnnnfc.enc<br />
</code><br />
You can get away without understanding the structure of the map file, but we need know the name LaTeX should use to refer to the font.  In this case it is the somewhat lengthy <code>TeXGyrePagella-Regular--custom--base</code>.  We could edit <code>custom.map</code> to give it a different name, but then we would need to make sure to rename the <code>tfm</code> files appropriately.  So we'll just leave it alone.</p>
<p>At this point we are ready to describe the font to LaTeX.  To to this we'll create a file called <code>UPagella.fd</code> where <code>fd</code> stands for "font definition".  Assuming you are using TeX Live, you can learn more about the format of font definition files by running: <code>texdoc fntguide</code>, which will bring up the <em>LATEX 2ε font selection</em> document. Put the following into <code>UPagella.fd</code>:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">UPagella.fd</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{m}{n}{ &amp;lt;-&amp;gt; TeXGyrePagella-Regular--custom--base }{</span>}
&nbsp;
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C4}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F8</span>}
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03B5}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F9</span>}
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C7}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;FA</span>}
&nbsp;</pre>
<p>The second line declares for the font encoding U, a font family named Pagella. The third line defines an available shape for the Pagella family.  It has a medium weight (m) and normal/upright (n), and for all sizes (&lt;-&gt;) the font named <code>TeXGyrePagella-Regular--custom--base</code> should be used.  The three <code>\DeclareUnicodeCharacter</code> lines map the Unicode glyphs for τ, ε, and χ to their locations in the encoding we defined.  Note that the hexadecimal numbers must all be in uppercase for LaTeX to parse them correctly.</p>
<p>Now we are all set to revisit our original example.  In <code>test.tex</code> enter:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\documentclass</span>{<span style="color: #2222D0; font-weight: normal;">article</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">utf8</span>]{<span style="color: #2222D0; font-weight: normal;">inputenc</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">U</span>]{<span style="color: #2222D0; font-weight: normal;">fontenc</span>}
<span style="color: #800000; font-weight: normal;">\pdfmapfile</span>{<span style="color: #2222D0; font-weight: normal;">+custom.map</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\rmdefault</span>}{Pagella</span>} 
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
&nbsp;</pre>
<p>The second line here tells LaTeX to load the <code>inputenc</code> package and pass it the option <code>utf8</code> to tell it to parse the remainder of the input as UTF8 encoded text.  The third line tells LaTeX to load the <code>fontenc</code> package and pass it the option <code>U</code> telling it to set the default encoding to be U.  The fourth line is specific to pdfTeX and tells it to add to its internal mapping the definitions in <code>custom.map</code>.  Finally, <code>\renewcommand</code> is used to change the default serif (Roman, rm) font to be Pagella.</p>
<p>We can now go ahead and run <code>pdflatex</code>:</p>
<pre>
% pdflatex test.tex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&amp;-line parsing enabled.
entering extended mode
(./test.tex
...
...
(./test.aux) (./upagella.fd) [1] (./test.aux) ){a_qnnnfc.enc}&lt;./TeXGyrePagella-
Regular.pfb&gt;
Output written on test.pdf (1 page, 22850 bytes).
Transcript written on test.log.
</pre>
<p>Again, we now get a PDF with the desired output:<br />
<a href='http://existentialtype.net/wp-content/uploads/2008/07/test2.png'><img src="http://existentialtype.net/wp-content/uploads/2008/07/test2.png" alt="pdfLaTeX test" title="test2" width="224" height="122" class="aligncenter size-full wp-image-255" /></a></p>
<p>That concludes the second part of the tutorial.  The third, and probably final, part of the tutorial will cover what needs to change in the above process if you would like to use a TrueType font rather than an OpenType font containing PostScript outline data.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
