Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7719605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:27:26+00:00 2026-06-01T03:27:26+00:00

people. I have slight problem with GD2 text on image. I have everything working

  • 0

people.

I have slight problem with GD2 text on image. I have everything working and now i try to add text on image that can wrap within image.

For example i have image with width 200px and large block of text. If you use imagettftext() text goes beyond borders of image and only partial text actually is visible. I have tried to use Zend’s text wrap function, but it’s not always producing accurate results here(not saying it don’t work, only not in this case).

Is there some dedicated GD2 method to set some width box where text should fit and if it hits border of that box it should continue in new line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T03:27:27+00:00Added an answer on June 1, 2026 at 3:27 am

    Not sure its what you looking for but, you can try this:

     function wrap($fontSize, $fontFace, $string, $width){
    
        $ret = "";
        $arr = explode(' ', $string);
    
        foreach ( $arr as $word ){
          $teststring = $ret.' '.$word;
          $testbox = imagettfbbox($fontSize, 0, $fontFace, $teststring);
         if ( $testbox[2] > $width ){
           $ret.=($ret==""?"":"\n").$word;
          } else {
            $ret.=($ret==""?"":' ').$word;
          }
        }
    
      return $ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a slight problem that I can't figure out, but should be really
Currently, I have a website that people can open up during a certain team's
Some people have suggested that when doing an estimate one should make a lower
Many people have argued about function size. They say that functions in general should
I have used several different scripts that people have suggested for trying to parse
I have noticed that sometimes people have to use multiple versions of jQuery in
Lots of people have things that their systems do for them or for their
I know that most people have DirectX9-capable cards but is it really necessary to
Some people have argued that the C# 4.0 feature introduced with the dynamic keyword
I have a collection(people) that has a many-to-many reference to another collection(dogs). Suspend your

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.