example from php.net का उपयोग करके मुझे एक चेतावनी मिलती है, और छवि सही ढंग से प्रस्तुत नहीं की जाती है। मैं तो जैसे .ttf फाइल करने के लिए एक पूर्ण पथ की आपूर्ति: /var/www/public/myfont.ttf
imagettftext फ़ॉन्ट फ़ाइल नहीं खोल सकता
PHP Warning: imagettftext() [<a href='function.imagettftext'>function.imagettftext</a>]: Could not find/open font in <phpfile>
मैं एक कस्टम का उपयोग कर रहा .ttf फ़ॉन्ट here पाया। मैं उबंटू में फ़ाइल को ठीक फ़ॉन्ट फ़ाइल के रूप में खोल सकता हूं। मैंने एक ही परिणाम के साथ अन्य फोंट का भी प्रयास किया।
मैं अपाचे 2, php5, freetype6 और php5-gd के साथ उबंटू 10.04 एलटीएस 32 बिट का उपयोग कर रहा हूं। मैंने उसी परिणाम के साथ, ttf फ़ाइल के साथ 777 फ़ाइल और फ़ोल्डर को chmod करने का भी प्रयास किया।
कस्टम टीटीएफ फ़ॉन्ट फ़ाइल का उपयोग करके मैं उदाहरण कैसे प्राप्त कर सकता हूं?
* संपादित करें: कोड मैं उपयोग कर रहा हूँ: phpinfo से
<?php
// File is: /var/www/public/test.php
// Apart from $font variable, it's copy-pasted from php.net
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(400, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = '/var/www/public/UnmaskedBB.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
आउटपुट();
[gd]
GD Support enabled
GD Version 2.0
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.3.11
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 6b
PNG Support enabled
libPNG Version 1.2.42
WBMP Support enabled
परीक्षण is_file
और is_readable
:
$font = realpath('./').'/UnmaskedBB.ttf';
echo "Font: ".$font; // /var/www/public/UnmaskedBB.ttf
echo "Is file? ".is_file($font); // 1
echo "Is readable? ".is_readable($font); // 1
क्या आप सही कोड दिखा सकते हैं? मैं कुछ भी गलत नहीं देख सकता लेकिन पूर्णता के लिए –
क्या आप 100% सुनिश्चित हैं कि फ़ॉन्ट का सटीक पथ है? खाता केस संवेदनशीलता लेना? –
और ऐसा लगता है कि एक टाइपो: 'tff' –