1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP GD - writing bold/italic text

Discussion in 'PHP' started by norfstar, Oct 3, 2005.

  1. #1
    I'm using imagettftext to write text on top of an image - and it all works well for normally formatted text. Unfortunately I can't seem to find out if it is possible to italicise or bold text in this method. Anyone know if it's possible? If so, what needs to be done?

    I'm aware that there are other tools available that will do this. ImageMagick is one of them, but for some reason the -draw text command doesn't have any effect when I've tried it (and I've tried it on three different hosts). If there is no way of doing it with PHP's GD library, I would also be interested in hearing any suggestions for alternative methods.
     
    norfstar, Oct 3, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    You can do it with PHP's GD library, you just need to use your own fonts (that support bold/italic, etc.)
     
    digitalpoint, Oct 3, 2005 IP
    norfstar likes this.
  3. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Shawn :) - you mean create font files that are already bolded or italicised right? I've no previous experience with doing this - are they any apps you would recommend?
     
    norfstar, Oct 3, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    Normally fonts are already built with italics or bold, etc. Like the Arial font for example is really made up of different versions (it's not applications that turn it into bold/italic when you want).
     
    digitalpoint, Oct 3, 2005 IP
  5. cjohnweb

    cjohnweb Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have a little tool I wrote in PHP that basically does the same thing that you are trying to accomplish, except it uses the specified font to output text.

    You provide the script with a .ttf (True Type Font) file, state your text/font size, color, etc etc and it outputs a png image. Some fonts have bold, italics built in, etc but you could just find an alternative .ttf font file to use....Not necessarily bold the text, just a different font.

    It has samples, and a code generator and another script I found to add reflection to the bottom of the image for really nice headers and things of the like....

    It's a small file, check it out!

    PHP GD Text<->PNG creator:
    http://iluvjohn.com/welcome-to-iluvjohn/custom-fonts-on-a-website-with-php-704/
     
    cjohnweb, Jul 24, 2010 IP