{"id":60,"date":"2008-02-15T13:32:23","date_gmt":"2008-02-15T20:32:23","guid":{"rendered":"https:\/\/www.wkiri.com\/today\/?p=60"},"modified":"2008-02-15T21:00:31","modified_gmt":"2008-02-16T04:00:31","slug":"how-to-embed-fonts-in-a-pdf-file","status":"publish","type":"post","link":"https:\/\/www.wkiri.com\/today\/?p=60","title":{"rendered":"How to embed fonts in a PDF file"},"content":{"rendered":"<p>This is an issue that comes up every now and then, for example when you create a PDF file that&#8217;s designed for actual printing (like in a book).  The fonts used by PDF (or PS) files can be either embedded or simply &#8220;linked&#8221; to fonts already installed on the system.  The advantage to linking is that the file size can be a lot smaller; the PDF file doesn&#8217;t need to carry around a full description of how to render each font.  Unfortunately, the destination system doesn&#8217;t always have the fonts you want.  The safest solution is to embed every font description in the PDF file.<\/p>\n<p>But how do you make this magic happen?  There are two important steps I learned about today.  (These apply to linux\/unix\/Mac systems.)<\/p>\n<blockquote><p>\n<b>1. Tell pdflatex, dvips, and dvipdf to embed the fonts.<\/b><\/p>\n<p>\nThe best instructions I&#8217;ve seen for this are <a href=\"http:\/\/axiom.anu.edu.au\/~luke\/embedded_fonts.html\">here<\/a>.  Basically, you run `updmap` to find out where your config file is, then edit it to indicate that you want the fonts to be embedded.  Re-run `updmap` to make those config settings stick, and then you can do pdflatex or dvips or dvipdf (as desired) to create files with embedded fonts.\n<\/p><\/blockquote>\n<p>That will get you most of the way there.  However, if you&#8217;re including figures (say, .eps files) that also have their own fonts that weren&#8217;t embedded, and those font names aren&#8217;t recognized, you may get an error like:<br \/>\n<tt><br \/>\ndvips: Font Helvetica used in file fancy_widget.eps is not in the mapping file.<br \/>\n<\/tt><br \/>\nYou can&#8217;t embed the font if your system doesn&#8217;t have a mapping for it.  Oops!  This usually happens with fonts like Helvetica, Times, and Symbol; these are proprietary font names, so their mappings aren&#8217;t found in most open source systems.  But you can fix this problem, as described in this <a href=\"http:\/\/www.grassbook.org\/neteler\/highres_pdf.html\">excellent font reference<\/a>, by replacing the font names with their open-source equivalents:<\/p>\n<blockquote><p>\n<b>2. Replace proprietary font names with their open-source equivalents.<\/b><\/p>\n<p>\nSince .eps is a text format, you can just open the .eps file in a text editor and search\/replace the font names.  Markus Neteler makes this even easier with a handy bit of sed:<br \/>\n<tt><br \/>\n   cat original_graphics.eps | sed 's+Times-Bold+NimbusSanL-Bold+g' |\\<br \/>\n   sed 's+Times-Roman+NimbusSanL-Regu+g' |\\<br \/>\n   sed 's+Times+NimbusSanL-Regu+g' |\\<br \/>\n   sed 's+Helvetica-BoldOblique+NimbusSanL-BoldItal+g' |\\<br \/>\n   sed 's+Helvetica-Oblique+NimbusSanL-ReguItal+g' |\\<br \/>\n   sed 's+Helvetica-Bold+NimbusSanL-Bold+g' |\\<br \/>\n   sed 's+Helvetica-Bold-iso+NimbusSanL-Bold+g' |\\<br \/>\n   sed 's+Helvetica+NimbusSanL-Regu+g' |\\<br \/>\n   sed 's+Helvetica-iso+NimbusSanL-Regu+g' |\\<br \/>\n   sed 's+Symbol+StandardSymL+g' > new_graphics.eps<br \/>\n<\/tt>\n<\/p><\/blockquote>\n<p>For the particular file I was working on today, a couple of additional fonts didn&#8217;t show up on Markus&#8217;s list.  They were all variants on the Courier font.  After some hunting around, I figured out that Courier is &#8220;Nimbus Mono L&#8221;, so here&#8217;s the translation:<br \/>\n<center><\/p>\n<table cellspacing=5>\n<tr>\n<td>Courier<\/td>\n<td>NimbusMonL-Regu<\/td>\n<\/tr>\n<tr>\n<td>Courier-Bold<\/td>\n<td>NimbusMonL-Bold<\/td>\n<\/tr>\n<tr>\n<td>Courier-Oblique<\/td>\n<td>NimbusMonL-ReguObli<\/td>\n<\/tr>\n<tr>\n<td>Courier-BoldOblique<\/td>\n<td>NimbusMonL-BoldObli<\/td>\n<\/tr>\n<\/table>\n<\/table>\n<p><\/center><\/p>\n<p>Finally, you may want to check the file to confirm that the fonts were embedded.  It seems that you can use a utility called &#8216;pdffonts&#8217; to do this from the command-line, but I don&#8217;t have it on my system.  Alternatively, you can fire up Adobe  Reader, go to &#8220;File->Document Properties&#8221;, click on the &#8220;Fonts&#8221; tab, and browse to see that each font is marked &#8220;embedded.&#8221;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is an issue that comes up every now and then, for example when you create a PDF file that&#8217;s designed for actual printing (like in a book). The fonts used by PDF (or PS) files can be either embedded or simply &#8220;linked&#8221; to fonts already installed on the system. The advantage to linking is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[23,2,27],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts\/60"}],"collection":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":0,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wkiri.com\/today\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}