Jump to content

Recommended Posts

I recently moved servers and since then I have noticed that one line of text is showing weirdly.

 

I have attached an example image that was generated. In the word 'Managing' the letters M & N are being distorted.

 

The bit of code that creates that line of text is...

 

$silk = 'fonts/slkscr.ttf';
$grey = imagecolorallocate($im, 49, 51, 61);
imagefttext($im, 6, 0, 73, 25, $grey, $silk, 'Managing');

 

[attachment deleted by admin]

It looks like font is not found and some default font(depends of the server) is assigned

 

u have font in that directory?

also u may try change font path to full path something like

 

$silk = '/host/host_suer_name/public_html/fonts/slkscr.ttf';

 

u can find this prefix by echoing $_SERVER['DOCUMENT_ROOT']

 

Thats how the font is supposed to look. Its kinda ugly if you ask me.

 

 

HTH

Teamatomic

 

It doesn't. Like I say i used it for months before hand. It only started looking like that when I changed server.

 

I have it on my PC and here is what it looks like...

 

 

 

[attachment deleted by admin]

Font size may cause it.

 

The font size. Depending on your version of GD, this should be specified as the pixel size (GD1) or point size (GD2).

 

So it probably server uses another GD version

 

I think that could be it. Except I have tried loads of different font sizes but to no avail. They all have the weird shaped M & N's. I have given up and resorted to using a different font now.

Can you recreate this with a basic image? E.g. does the following still produce the mangled letters?

 

<?php

$im = imagecreatetruecolor(100, 50);

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 49, 51, 61);

imagefill($im, 0, 0, $white);
imagerectangle($im, 0, 0, 99, 49, $grey);

$silk = 'fonts/slkscr.ttf';
imagettftext($im, 6, 0, 25, 22, $grey, $silk, 'Managing');
imagettftext($im, 6, 0, 25, 32, $grey, $silk, '(GD '.GD_VERSION.')');

header('Content-Type: image/png');
imagepng($im);
exit;

 

Also where did you get the font file from, did you use the one from kottke.org?

Can you recreate this with a basic image? E.g. does the following still produce the mangled letters?

 

Yes it does (see attachment).

 

Also where did you get the font file from, did you use the one from kottke.org?

 

Yes I believe so. It's been on my computer a long time now though so I am not 100% sure.

 

[attachment deleted by admin]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.