2011-04-06 93 views
2

這是錯誤消息我得到當我改變一個有效的網站的環境:問題使用字體與imagettftext

Warning: imagettftext() [function.imagettftext]: Could not find/open font 

首先,我想這是由於缺少對文件的權利卡梅斯,但它不「T,I檢查路徑和設置中的所有文件777 ...... 後來我查GD,它看起來像它安裝:

GD Support enabled 
GD Version bundled (2.0.34 compatible) 
FreeType Support enabled 
FreeType Linkage with freetype 
FreeType Version 2.3.5 
GIF Read Support enabled 
GIF Create Support enabled 
JPG Support  enabled 
PNG Support  enabled 
WBMP Support enabled 
XBM Support  enabled 

我試圖使用ARIAL.TTF,所以沒有太多的異國情調,我猜... 任何想法從哪裏開始看?

THX

回答

3

如果您正在使用的字體是與腳本相同的目錄(在beggining沒有前導/),鍵入剛剛arial沒有.ttf。如果它在另一個目錄中,則必須包含.ttf。順便說一句:如果你可以添加你使用的代碼,這將是很好的。

因此,這裏是示例代碼:

# Correct 
$font = 'arial'; 

# Wrong 
$font = 'arial.ttf'; 


# Correct 
$font = '/fonts/arial.ttf'; 

# Wrong 
$font = '/fonts/arial'; 

PHP.NET說:

根據其GD 庫PHP的版本使用,當fontfile 不以領先/然後開始 .ttf將附加到文件名 後,並且該庫將嘗試搜索 沿着 library-de罰款的字體路徑。

+0

這是它的樣子:var_dump($ this-> font); // string'/ Shared \ Websites/largos/largos_site/trunk/commun/font/arialbd.ttf' imagettftext($ this-> im,$ font_size,0,$ x,$ y,$ this-> textcolor,$ this-> font,$ chaine); – krifur 2011-04-06 13:08:16

+0

對不起,我不知道如何正確顯示「評論」 – krifur 2011-04-06 13:10:23