Hi There,

I seem to have a problem with the installation and hope someone can help me out.

Running the latest version of Drupal. On installing the module, I get the following error:

Fatal error: Call to undefined function: str_split() in /home/rastarr/public_html/drupal/sites/www.it-painkillers.com/modules/magick/magick_ttf.inc on line 44

I've confirmed Imagemagick is installed and the right location with my webhost. I've set up a preset (no spaces in title) with a defined parameters, then proceeded to load the TTF and get the error.

There is a 'font' subdirectory created in the /files/magick/ directory but no font has been uploaded.

Any ideas?
Cheers
Martin

Comments

rastarr’s picture

Also tried on another domain without a ' - ' in the domain name as well as other fonts however same error

rastarr’s picture

From my webhost who's kindly checked out the error for me.

Please check : http://us2.php.net/str_split . The function was introduced in php5. Your domain is not using php5. You need to switch your domain to php5 for that function to work.

Seems you should probably state somewhere that this module is for PHP5 only - might save some support woes. Now to look for anything that's PHP4 friendly.

rhys’s picture

Title: error on installation » Doesn't work with PHP5

I apologize for the PHP5 nature of the file. If you add the following code to beginning of the magic_ttf.inc, it should function. However, this is untested, as everything I have is using PHP5. Please let me know if it has problems. If this functions without problems, I will immediately add it to the CVS.

if (!function_exists('str_split')) {

function str_split( $string, $split_length ) {
  $a = array();
  $max = strlen( $string );
  $i = 0;
  $count = 0;
  $current = '';
  while ($i < $max) {
    if ($count >= $split_length) {
      if ($current)
        $a[] = $current;
      $current = '';
      $count = 0
    }
    $current .= $string{$i};
    $i++;
  }
  if ($current) {
    $a[] = $current;
  }
  return $a;
}

}
rhys’s picture

Or better yet, change the line in magic_ttf.inc line 44 from

  $table_entries = str_split($contents, 16);

to

  $table_entries = chunk_split($contents, 16);

This should work for PHP4 and PHP5.

rhys’s picture

Status: Active » Fixed

This has been updated in HEAD.

rastarr’s picture

Actually, in the meantime, I contacted my host who gave me a line to add in the .htacess file so the Drupal site can use PHP5.
I now have a font loaded.

I'm now looking for some doco on how to actually use it in, say, a Title or something like that. This was my original intention.
Do you have any documentation or examples around that I've missed? Pardon the question however I'm kinda new at Drupal so I've probably overlooked something along the way.

Cheers and thanks for your help thus far. Drupal community is pretty great.
Martin

rhys’s picture

I'll write something as soon as I get the time. In the meantime, try the following things.

Create a magick preset, called somthing like "menu", set pointsize to 12 (which is 12pt in CSS terms), set the font to the one you just uploaded, then add this into your theming where you would like the label to be displayed. Note: this only displays the image, it doesn't create a link for it, yet.
Also, if you play with some of the settings, remember that your browser will need to reload the picture, since it sits in the cache.

      print magick_display_label("menu", 'Title here', "gif", array( 'class' => 'menu_label' ));

I hope this is enough to get you start, if not, create another issue, and we can continue there. This issue is different that what you require.

Anonymous’s picture

Status: Fixed » Closed (fixed)