Foros del Web » Programando para Internet » PHP »

Uso de imagettftext

Estas en el tema de Uso de imagettftext en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 24/07/2009, 10:04
 
Fecha de Ingreso: junio-2009
Mensajes: 11
Antigüedad: 14 años, 10 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>
  #2 (permalink)  
Antiguo 12/09/2009, 16:43
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Uso de imagettftext

Hola
El parametro font entonces no te sirve para cambiar de fuente???
y si lo intentas en un html como lo hiciste en el ej te da algún error?
nos cuentas, saludos
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:26.