text effects with the GD graphic library

Discussion in 'PHP' started by NoamBarz, Jan 27, 2008.

  1. #1
    I am currently building an application that creates images on the fly using GD.
    I let the user enter text in an HTML form, pass the info to a php script and create the image.

    I would like to allow the user to create bold, italic or underlined text. For bold and italic, all I need to do is select the correct TrueType font file. The problem is with underlined text. There doesn't seem to be a function I can use.

    I found an entry stating that if you pass the text along the querystring, you can add "%0D_____" to the end of the text and it will be underlined. The problem is that this solution isn't precise enough. Sometimes the underline is a little shorter than the text and sometimes the opposite happens.

    Alternatively, I could fond out what the length of the textbox is and draw a line under the text with the exact length. However, this seems like a risky approach since the underline may not look exactly like that of the HTML <u> element </u>.

    Can anyone sugget a way around this problem?
     
    NoamBarz, Jan 27, 2008 IP