{"id":21,"date":"2006-11-29T13:28:03","date_gmt":"2006-11-29T11:28:03","guid":{"rendered":"http:\/\/blog.ansuz.nl\/index.php\/2006\/11\/29\/dompdf-experiment-pt2-installing-a-font\/"},"modified":"2008-04-13T16:49:37","modified_gmt":"2008-04-13T14:49:37","slug":"dompdf-experiment-pt2-installing-a-font","status":"publish","type":"post","link":"http:\/\/blog.ansuz.nl\/index.php\/2006\/11\/29\/dompdf-experiment-pt2-installing-a-font\/","title":{"rendered":"dompdf experiment pt2 &#8211; installing a font"},"content":{"rendered":"<p>The default fonts that come with pdf aren&#8217;t enough for me, so I want to install a new font. To do so you need to have <a href=\"http:\/\/ttf2pt1.sourceforge.net\/\" target=\"_blank\">ttf2pt1<\/a> installed on the webserver. Unfortunately that&#8217;s not the case for me. The dompdf manual says the following about having problems installing fonts:<\/p>\n<blockquote><p>Also, if you have problems installing the font files, you can try and use the distributed dompdf_font_family_cache.dist file in lib\/fonts.  Copy this file to lib\/fonts\/dompdf_font_family_cache and edit it directly to match the files present in your lib\/fonts directory.<\/p><\/blockquote>\n<p>Let&#8217;s see if this will work&#8230;<\/p>\n<p>EDIT: Ok, found a nice .afm font (serpentine), put it in the lib\/fonts dir of dompdf 0.5.1 and edited the <em>dompdf_font_family_cache<\/em> file, the following has been added:<\/p>\n<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">php<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"php\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">'serpentine'<\/span> <span style=\"color: #339933\">=&amp;<\/span>gt<span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #990000\">array<\/span> <span style=\"color: #009900\">&#040;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">'normal'<\/span> <span style=\"color: #339933\">=&amp;<\/span>gt<span style=\"color: #339933\">;<\/span> DOMPDF_FONT_DIR <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'SerpeMed'<\/span><span style=\"color: #339933\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">'bold'<\/span> <span style=\"color: #339933\">=&amp;<\/span>gt<span style=\"color: #339933\">;<\/span> DOMPDF_FONT_DIR <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'SerpeBol'<\/span><span style=\"color: #339933\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">'italic'<\/span> <span style=\"color: #339933\">=&amp;<\/span>gt<span style=\"color: #339933\">;<\/span> DOMPDF_FONT_DIR <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'SerpeMedObl'<\/span><span style=\"color: #339933\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #0000ff\">'bold_italic'<\/span> <span style=\"color: #339933\">=&amp;<\/span>gt<span style=\"color: #339933\">;<\/span> DOMPDF_FONT_DIR <span style=\"color: #339933\">.<\/span> <span style=\"color: #0000ff\">'SerpeBolObl'<\/span><span style=\"color: #339933\">,<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#041;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>When I try to make a pdf using this font with dompdf an error is thrown and no pdf is generated&#8230;<\/p>\n<ul>\n<li>html page: <a href=\"http:\/\/vilarricatest.nl.php5.nognietonline.eu\/test\/dompdf\/www\/test\/vilarrica\/viltest02.html\" target=\"_blank\">html<\/a><\/li>\n<li>pdf generation: <a href=\"http:\/\/vilarricatest.nl.php5.nognietonline.eu\/test\/dompdf\/dompdftest02.php\" target=\"_blank\">pdf<\/a><\/li>\n<li>thread @ sourceForge: <a href=\"http:\/\/sourceforge.net\/forum\/message.php?msg_id=4035984\" target=\"_blank\">installing a font<\/a><\/li>\n<\/ul>\n<p><em>To be continued&#8230;<\/em><\/p>\n<p>Edit: An .atm AND .pfa or .pfb file are required to make it work. So now it works great! \ud83d\ude42<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>The default fonts that come with pdf aren&#8217;t enough for me, so I want to install a new font. To do so you need to have ttf2pt1 installed on the webserver. Unfortunately that&#8217;s not the case for me. The dompdf &hellip; <a href=\"http:\/\/blog.ansuz.nl\/index.php\/2006\/11\/29\/dompdf-experiment-pt2-installing-a-font\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/comments?post=21"}],"version-history":[{"count":0,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/media?parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/categories?post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ansuz.nl\/index.php\/wp-json\/wp\/v2\/tags?post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}