Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/07/2009, 10:04
naruto05
 
Fecha de Ingreso: junio-2009
Mensajes: 11
Antigüedad: 15 años, 8 meses
Puntos: 0
Uso de imagettftext

Tengo la ste clase implementada para crear imagenes con el tipo de letra que desee, ya que no encontre la forma de usar esa fuente como una si usara Verdana u otra.

He aqui la clase:
Código PHP:
<?php
header
('Content-type: image/png');
class 
GenerateTextFromFont{
    
//Generate the text with font selected
    
function createText($width,$height,$size,$color,$background,$font,$text){
        
// Create the image
        
$img imagecreatetruecolor($width$height);
        
//Color text and color of background
        
$color=imagecolorallocate($img$color[0], $color[1], $color[2]);
        
$background=imagecolorallocate($img$background[0], $background[1], $background[2]);
        
imagefilledrectangle($img00$width$height$background);
        
//Set properties
        
imagettftext($img$size01$size$color$font$text);
        
//Results
        
imagepng($img);
        
imagedestroy($img);
    }
}
?>
Ahora el archivo de donde la llamo:
Código PHP:
<?php
include('GenerateText.php');
//Instance of GenerateText
$objGenerateText=new GenerateTextFromFont();
//$objGenerateText->createText(70, 15, 10, array(10,100,100),array(255,255,100), 'Fonts/FIRESTARTER.TTF', "Tester...");
$objGenerateText->createText(701515, array(10,100,100),array(255,255,255), 'Fonts/gothica_class_2.ttf'"Tester...");
?>
El error se genera cuando intento incluir eso dentro de <html> y respectivamente </html>, ya que en la clase esta header('Content-type: image/png');, entonces como puedo hacer uso de esa clase dentro de un archivo php con la ste estructura:
Código PHP:
<html>
    <head>
        <title>Uso de fuentes</title>
    </head>
    <body>
    <table>
        <tr><td>
    <?php
     
include('GenerateText.php');
     
//Instance of GenerateText
     
$objGenerateText=new GenerateTextFromFont();
     
$objGenerateText->createText(701510, array(10,100,100),array(255,255,100), 'Fonts/FIRESTARTER.TTF'"Tester...");
    
?>
    </td></tr>
    </table>
    </body>
</html>