{"id":1334,"date":"2004-09-07T13:49:10","date_gmt":"2004-09-07T13:49:10","guid":{"rendered":"http:\/\/sunpig.com\/mt-entry-1334.html"},"modified":"2006-09-23T19:30:11","modified_gmt":"2006-09-23T19:30:11","slug":"rosenberger-image-replacement","status":"publish","type":"post","link":"https:\/\/sunpig.com\/martin\/2004\/09\/07\/rosenberger-image-replacement\/","title":{"rendered":"Rosenberger Image Replacement"},"content":{"rendered":"<p>I&#8217;ve been playing around with Stewart Rosenberger&#8217;s excellent <a href=\"http:\/\/www.alistapart.com\/articles\/dynatext\/\">Dynamic Text Replacement<\/a> technique lately.  It&#8217;s a simple and elegant technique, and it works beautifully well with TrueType fonts.  It gets a little bit more tricky if you want to use PostScript fonts, though.  On the ALA discussion, Stewart <a href=\"http:\/\/www.alistapart.com\/discuss\/dynatext\/14\">says<\/a> that <cite>&#8220;you could change the PHP script to use PS fonts very easily&#8221;<\/cite>.  Well&#8230;.<\/p>\n<ul>\n<li>It&#8217;s not as simple as replacing the <code>ImageTTFBBox<\/code> and <code>ImageTTFText<\/code> calls with their PostScript counterparts <code>ImagePSBBox<\/code> and <code>ImagePSText<\/code>.  The PS versions take different parmeters in a different order, and they return a different results array.  Read the <a href=\"http:\/\/uk.php.net\/manual\/en\/function.imagepsbbox.php\">documentation<\/a> carefully.<\/li>\n<li>&#8230;and you&#8217;ll need to explicitly <a href=\"http:\/\/uk.php.net\/manual\/en\/function.imagepsloadfont.php\">load the PostScript font<\/a> before using it, and <a href=\"http:\/\/uk.php.net\/manual\/en\/function.imagepsfreefont.php\">dispose of it<\/a> when you&#8217;re done.<\/li>\n<li>&#8230;and once you&#8217;ve done all that work, you need to make sure that your web host has compiled PHP with support for Type 1 PostScript fonts, using the <kbd>--with-t1lib<\/kbd> option, because otherwise you&#8217;ll get nothing but errors when you try to deploy.<\/li>\n<\/ul>\n<p>Nuts.  Maybe I should have checked that last step first.<\/p>\n<p>If you have access to a copy of Windows NT4 (how quaint!), you can convert a Type 1 font into a TrueType font by dragging it into the Windows\\Fonts folder.  (NT generates a .ttf font because it doesn&#8217;t have native PS support.  Later versions of Windows <em>do<\/em> have native support, and so they don&#8217;t do the conversion when you install a PS font.)  The quality of the generated TrueType font leaves a lot to be desired, however, and even aside from the licensing issues, I wouldn&#8217;t consider it as a source for Dynamic Text Replacement.<\/p>\n<p>So what next?  Well, I could rewrite Stewart&#8217;s script to use <a href=\"http:\/\/www.imagemagick.org\/\">ImageMagick<\/a> for generating the images.  Alternatively, I could try Shaun Inman&#8217;s <a href=\"http:\/\/www.shauninman.com\/mentary\/past\/ifr_revisited_and_revised.php\">Flash Replacement<\/a> technique.  (I&#8217;d prefer to stick with images instead of Flash, though.  The text isn&#8217;t selectable, and you end up with a bigger download, but images are faster to render, have fewer flickering issues, and fewer cross-browser\/standards niggles.)  Or I could splash out and buy a TrueType version of the font I want to use.  Or&#8230;I could just use a font I already have in TrueType format.  Such a wealth of choice!<\/p>\n<p>I think I&#8217;ll be taking the easy, cheap option.<\/p>\n<h4>Update (Thu 8 Sept 2004)<\/h4>\n<p>Mike Davidson&#8217;s <a href=\"http:\/\/www.mikeindustries.com\/blog\/archive\/2004\/08\/sifr\">Scalable Inman Flash Replacement technique<\/a> (sIFR) is looking like a glorious alternative.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been playing around with Stewart Rosenberger&#8217;s excellent <a href=\"http:\/\/www.alistapart.com\/articles\/dynatext\/\">Dynamic Text Replacement<\/a> technique lately.  It&#8217;s a simple and elegant technique, and it works beautifully well with TrueType fonts.  It gets a little bit more tricky if you want to use PostScript fonts, though.  On the ALA discussion, Stewart <a href=\"http:\/\/www.alistapart.com\/discuss\/dynatext\/14\">says<\/a> that <cite>&#8220;you could change the PHP script to use PS fonts very easily&#8221;<\/cite>.  Well&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-1334","post","type-post","status-publish","format-standard","hentry","category-design"],"_links":{"self":[{"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/posts\/1334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/comments?post=1334"}],"version-history":[{"count":0,"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/posts\/1334\/revisions"}],"wp:attachment":[{"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/media?parent=1334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/categories?post=1334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunpig.com\/martin\/wp-json\/wp\/v2\/tags?post=1334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}