How to convert font size into pixels or pixles to font size?

Discussion in 'PHP' started by globalcashsite, Dec 23, 2009.

  1. #1
    Guys

    I have created an image in php that's size is 160 x 225. It means my image's width is 160 pixels.

    Now I wish to put text on it just like "PAYING", font size 10 and face is ARIAL. I wish to put this text in center of image. I am confused how to convert font size 10 into pixel or 160 pixels into font size?

    Any formula?

    GlobalCashSite
     
    globalcashsite, Dec 23, 2009 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    I am not quite sure what you are asking. Can you explain it a little better?
     
    Pudge1, Dec 23, 2009 IP
  3. globalcashsite

    globalcashsite Peon

    Messages:
    806
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi buddy

    I created one image with php's image.....() function that's size is in pixels i.e. 160 x 225.

    Now I want to add text on it like "PAYING". The text's normal font size is 10. I wish to place this text in center of newly created image. I want to have a formula that automatically calculates text length and then decide at which point to add text so it looks in center.

    Text length will be different like "PAYING" or "NOT PAYING" or "WAITING" so I need formula that automatically decide where to place text.

    Font size and image size is in different unit.

    I am sure now you understand it.

    GCS
     
    globalcashsite, Dec 23, 2009 IP
  4. ThomasTwen

    ThomasTwen Peon

    Messages:
    113
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey,


    I'm not quite sure what you want to do, but I think it's possible using this function: http://www.php.net/manual/en/function.imagettfbbox.php


    It basically gives you the coordinates of the corners that a given text has, when you write it on a certain image in a certain size and certain font. The height of the text is the difference between the coordinates.


    Why do you try to create this image with PHP? The "Paying"-image is usually shown to all users as the same image, so you should rather create one with Photoshop or GIMP, and not with PHP.
     
    ThomasTwen, Dec 23, 2009 IP