2 Replies - 1274 Views - Last Post: 20 March 2012 - 09:25 AM Rate Topic: -----

#1 jonesa01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 25
  • View blog
  • Posts: 125
  • Joined: 18-February 07

PHP GD - Using fonts & font sizing

Posted 20 March 2012 - 04:12 AM

I am building a php script that will produce a series of images that have been pre-defined. All of which are one char long for example a-g

The user enters the font size, chooses font colour and uploads there chosen font in a form. All this is fine. But the trouble is I cannot load the font as it shows this error:

Warning: imageloadfont() [function.imageloadfont]: Error reading font

I move the uploaded font to a unique folder and I load the font using this code:

$font = imageloadfont("86241335505414019032012/BAUHS93.TTF");



I have downloaded the font and it works fine (loads correctly), so I am not sure why the error is there, it is before I set the new image up because I need to be able to work out the image size which is another problem I am having.

I need the image to be the font size i.e 12px of the specific font plus a 10px border on each side. The problem is how do i find out the height and the width of the font taking into account the font size?

All the rest of the script is fine but these two problems I have not found a way to fix so I hope soneone here could point me in the right direction to solve this.

Is This A Good Question/Topic? 0
  • +

Replies To: PHP GD - Using fonts & font sizing

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,259
  • Joined: 08-June 10

Re: PHP GD - Using fonts & font sizing

Posted 20 March 2012 - 05:06 AM

it looks like imageloadfont() only accepts GD fonts (.gdf). a workaround for .ttf is described in the user comments.
Was This Post Helpful? 2
  • +
  • -

#3 jonesa01  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 25
  • View blog
  • Posts: 125
  • Joined: 18-February 07

Re: PHP GD - Using fonts & font sizing

Posted 20 March 2012 - 09:25 AM

Thank you, I found the way to do it and that bit seems to work fine. I have also solved the font height/width by using the values returned by the function used to create the text.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1