<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Load a PostScript Type 1 font from file</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagepsfreefont.html">imagepsfreefont</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepsslantfont.html">imagepsslantfont</a></div> <div class="up"><a href="ref.image.html">GD and Image Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.imagepsloadfont" class="refentry"> <div class="refnamediv"> <h1 class="refname">imagepsloadfont</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">imagepsloadfont</span> — <span class="dc-title">Load a PostScript Type 1 font from file</span></p> </div> <div class="refsect1 description" id="refsect1-function.imagepsloadfont-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>imagepsloadfont</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span> )</div> <p class="para rdfs-comment"> Load a PostScript Type 1 font from the given <em><code class="parameter">filename</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.imagepsloadfont-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">filename</code></em></span> <dd> <p class="para"> Path to the Postscript font file. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.imagepsloadfont-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> In the case everything went right, a valid font index will be returned and can be used for further purposes. Otherwise the function returns <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 examples" id="refsect1-function.imagepsloadfont-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-3268"> <p><strong>Example #1 <span class="function"><strong>imagepsloadfont()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// Create a new image instance<br /></span><span style="color: #0000BB">$im </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">350</span><span style="color: #007700">, </span><span style="color: #0000BB">45</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Allocate colors and fill the background<br /></span><span style="color: #0000BB">$black </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$white </span><span style="color: #007700">= </span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">, </span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagefilledrectangle</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">349</span><span style="color: #007700">, </span><span style="color: #0000BB">44</span><span style="color: #007700">, </span><span style="color: #0000BB">$white</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Load a font, write to the image and free the font from memory<br /></span><span style="color: #0000BB">$font </span><span style="color: #007700">= </span><span style="color: #0000BB">imagepsloadfont</span><span style="color: #007700">(</span><span style="color: #DD0000">"bchbi.pfb"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagepstext</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">, </span><span style="color: #DD0000">"Testing... It worked!"</span><span style="color: #007700">, </span><span style="color: #0000BB">$font</span><span style="color: #007700">, </span><span style="color: #0000BB">32</span><span style="color: #007700">, </span><span style="color: #0000BB">$white</span><span style="color: #007700">, </span><span style="color: #0000BB">$black</span><span style="color: #007700">, </span><span style="color: #0000BB">32</span><span style="color: #007700">, </span><span style="color: #0000BB">32</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagepsfreefont</span><span style="color: #007700">(</span><span style="color: #0000BB">$font</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Output the image<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type: image/png'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.imagepsloadfont-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is only available if PHP is compiled using <strong class="option configure">--with-t1lib[=DIR]</strong> . </span></p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.imagepsloadfont-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.imagepsfreefont.html" class="function" rel="rdfs-seeAlso">imagepsfreefont()</a> - Free memory used by a PostScript Type 1 font</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.imagepsfreefont.html">imagepsfreefont</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.imagepsslantfont.html">imagepsslantfont</a></div> <div class="up"><a href="ref.image.html">GD and Image Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>