What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help needed

PHP help needed
Author: Message:
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: PHP help needed
It does work with ttf files if you're using GD2, you just need to put the absolute path to the ttf (I've experienced problems when refering to a relative path).

Thas algorithm first separated all word in the string and put them into an array (splitting the spaces). After that we rejoin the whole array into a new variable ($out1) and check the length. If it's too long, we decrement $split (which is the last piece of the array we will join into $out1). This means thatwe will try each time one word less until it no longer isbigger than maxlen.

Once this done, we keep $out1 and rejoin the rest of the array into $out2.

Having $out2, you can repeat the process as if it was the original text: split, join decrementally until it fits, join the rest into a new variable $out3. And so on
code:
// Keystorms Improvemend by slicing

$slices = explode(' ',$textRegel); 
$split = count($slices);
do{
$split--;
$out1 = NULL;
for($i=0;$i<=$split;$i++)
{
$out1 .= $slices[$i]." ";
}

$break = imagettfbbox($size,$angle,$fontpath,$out1);
} while ($break[2] > $maxlen);
$out2 = NULL;
for($j=$i; $j<count($slices); $j++)
{
$out2 .= $slices[$j].' ';
}

$slices = explode(' ',$out2); 
$split = count($slices);
do{
$split--;
$out2 = NULL;
for($i=0;$i<=$split;$i++)
{
$out2 .= $slices[$i]." ";
}

$break = imagettfbbox($size,$angle,$fontpath,$out2);
} while ($break[2] > $maxlen);
$out3 = NULL;
for($j=$i; $j<count($slices); $j++)
{
$out3 .= $slices[$j].' ';
}
...


Edit: I forgot to remind you about the height of the image. Check whether $out2, $out3 and $out4 are filled with something (strlen($outX) > 0, for example) and decide the height from those checks.

This post was edited on 04-18-2005 at 01:00 PM by KeyStorm.
04-18-2005 12:56 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
PHP help needed - by Ezra on 04-17-2005 at 05:22 PM
RE: PHP help needer - by KeyStorm on 04-17-2005 at 05:53 PM
RE: PHP help needer - by Ezra on 04-17-2005 at 07:32 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 08:56 PM
RE: PHP help needed - by Ezra on 04-17-2005 at 09:25 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 09:42 PM
RE: PHP help needed - by Ezra on 04-17-2005 at 09:47 PM
RE: PHP help needed - by KeyStorm on 04-17-2005 at 09:54 PM
RE: PHP help needed - by Ezra on 04-18-2005 at 12:07 PM
RE: PHP help needed - by KeyStorm on 04-18-2005 at 12:56 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On