php gd changing font

Discussion in 'PHP' started by crazyryan, Oct 14, 2006.

  1. #1
    
    <?php
    header("Content-type: image/png");
    $string = $_GET['image'];
    
    $im = imagecreatefrompng("http://www.habboname.com/nerd/brap.png");
    // white background and blue text
    $bg = imagecolorallocate($im, 255, 255, 250);
    $textcolor = imagecolorallocate($im, 0, 0, 255);
    
    // write the string at the top left
    imagestring($im, 5, 0, 0, "$string", $textcolor);
    
    // output the image
    imagepng($im);
    ?> 
    
    PHP:
    Does anyone know how I can change the font? The location of the font is http://www.habboname.com/nerd/volter.ttf.

    Thanks, will +rep all helpful posts.
     
    crazyryan, Oct 14, 2006 IP
  2. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    streety, Oct 14, 2006 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    Oh you have to be kidding me. Nevermind, I hardly know PHP and getting what I have now took me like a day. Thanks though.
     
    crazyryan, Oct 14, 2006 IP
  4. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It should just be a question of changing that one line 11.

    Like I say, if you have any problems let me know and I'll try and help. I remember doing something similar for a dynamic signature I wanted to put together a while ago.
     
    streety, Oct 14, 2006 IP
  5. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #5
    Nope, when I changed line 11 I got the image cannot be displayed because it contains error.
     
    crazyryan, Oct 14, 2006 IP
  6. streety

    streety Peon

    Messages:
    321
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I love gd errors, they're just so informative!

    I think line 11 should be something like

    imagettftext($im, 20, 0, 11, 21, $textcolor, "volter.ttf", $string);
    PHP:
    You also supposedly need the following at the very end after imagepng

    imagedestroy($im);
    PHP:
     
    streety, Oct 14, 2006 IP
    crazyryan likes this.
  7. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #7
    Dude, thank you so much! I gave you rep!!!
     
    crazyryan, Oct 14, 2006 IP