<?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; tex gyre pagella</title>
	<atom:link href="http://existentialtype.net/tag/tex-gyre-pagella/feed/" rel="self" type="application/rss+xml" />
	<link>http://existentialtype.net</link>
	<description>For People Who Like Type and Types</description>
	<lastBuildDate>Sat, 12 May 2012 16:35:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</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>
	</channel>
</rss>

