2010-04-28 54 views
4

我使用GD來顯示一些文本。默認字體是Courier(或類似的)...我想使用另一種字體,我發現這個功能:imageloadfont需要一個.gdf文件。我在谷歌上搜索,看看我是否找到一些不錯的字體,但我沒有找到任何東西。我看到有一個將PNG文件轉換爲GDF的腳本,但我不能浪費太多時間,所以我想知道我可以在哪裏獲得一些漂亮的字體,或者有另一種更簡單的方法來實現我想要的效果。我在哪裏可以找到GD兼容字體?

+3

爲什麼不使用GD的TrueType功能? – 2010-04-28 16:51:53

回答

6

我還沒有看到文檔中imagettftext功能。感謝@Pekka的建議。最後,我剛纔複製的consolas.ttf文件中的腳本的同一目錄下,做:

imagettftext ($image, 12, 0, 200, 100, 0, 'consolas.ttf' , "thanks!"); 

它完美。

2

您是否嘗試過使用轉換器將truetype字體文件轉換爲gdf?

http://www.lunar.lu/ttf-to-gdf/convert.php

+0

感謝您的幫助。我試圖轉換'Consolas',但結果不好:http://i.imgur.com/BpPWc.png再次感謝! – Cristian 2010-04-28 18:48:49

+0

啊我想它不會很好地消除鋸齒。但我發現你已經找到了你正在尋找的解決方案:) – Mark 2010-04-28 20:59:32

+4

我認爲即使鏈接現在已被打破,我得到了「404」 – 2012-03-28 05:18:33

-3
<div style="background:#ffffff; 
       border:5pt solid #000000;. 
       color:#000000; 
       padding:25px; 
       border-radius:15px;"> 
     <div> 
      <a href="http://kr1.php.net/imagettftext"> 
       http://kr1.php.net/imagettftext 
      </a> 
     </div> 

     <div> 
      an example... 
     </div> 

    <?php 
     $str = "TESTING..."; 
     @$i = imagecreate(strlen($str)*20+40,70) or die("FAILED..."); 
     magettftext($i,20,30,20,20,imagecolorallocatealpha($i,0,0,0,75),"굴림.ttf",$str); 
    ?> 

對不起...我無法測試......但也許這是正確的。아참고로난중2

+0

請格式化這很好,因爲沒有人能理解這一點。通過使用4個空格縮進每行,堆棧溢出具有很好的嵌入式代碼功能。 – Tim 2015-12-08 10:52:05

0

考慮的很好格式化張貼由「曲奇」(所以我的代碼的自由可以看到它自己;):

<div style="background:#ffffff;border:5pt solid #000000; color:#000000;padding:25px;border-radius:15px;"> 
    <div> 
     <a href="http://kr1.php.net/imagettftext">http://kr1.php.net/imagettftext</a> 
    </div> 
</div> 
<div>an example...</div> 
<?php 
    $str = "TESTING..."; 
    @$i = imagecreate(strlen($str)*20+40,70) or die("FAILED..."); 
    imagettftext($i,20,30,20,20,imagecolorallocatealpha($i,0,0,0,75),"굴림.ttf",$str) 
?> 
相關問題