473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

TTF text bounding box problem (imagettftext)

ljb
Using PHP-4.3.11 with GD extension, bundled GD library, and freetype-2.1.9
(with X.org 6.8.1). I can't get the TrueType Font (TTF) bounding box to
come out right. Whether using imagettftext() or imagettfbbox(), for some
angles of text (like 45 degrees), the box comes back in the wrong place.
Sample code below; just change the $font assignment to point to a TTF font
file. You should see a text string with a box around it, but my box isn't
always around the text, depending on the $angle.

Could someone please sanity check this before I open a bug report?

<?php
# PHP GD TTF Bounding Box Test
# Change this to the full path of a TrueType font you have:
$font = '/usr/local/lib/fonts/truetype/arial.ttf';
$size = 36.0;
$angle = 135.0; # Try 45, 135, 260 degrees for example

$g = imagecreate(800, 600);
$white = imagecolorallocate($g, 255, 255, 255);
$black = imagecolorallocate($g, 0, 0, 0);
# Draw the text string:
$bbox = imagettftext($g, $size, $angle, 400, 300, $black, $font, 'ABCDEF');
# Draw the bounding box:
imagepolygon($g, $bbox, 4, $black);

header("Content-type: image/png");
imagepng($g);
Jul 17 '05 #1
0 1919

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Wellesz | last post by:
Hi, since I've upgraded to php 4.3.4 (before I used 4.1.2) I have a problem with imagettftext(): when executing the line: imagettftext($im, 20, 0, 10, 25, $white, "$script_dir/verdana.ttf",...
0
by: Leif Wessman | last post by:
I'm using a bundled version of GD: 2.0.23 compatible. When using the function imagettftext() with a negative color to get a aliased text, the text gets grainy. What could be wrong? I've tried...
20
by: Jukka K. Korpela | last post by:
I recently noticed, once again, how the common implementation of italics can really disturb. I'm referring to the common phenomenon that there is by default too little spacing after italics text,...
1
by: Krustov | last post by:
The following works fine - but would like to center the text . Whats the best way to do it ? . <?php $text=$kk;
3
by: toffee | last post by:
Hi all, not sure if this is possible in PHP - every couple of weeks; i get a few png files; which i th open in an image editor; add a text box with comments in the top right corner; save the...
5
by: avlee | last post by:
Hello i have a code: /* some code creating picture */ header("Content-type: image/jpeg"); imagepng($new); it draws my picture correctly. But what to do when i want to draw a picture on my...
6
by: -Lost | last post by:
Anyone know offhand how to center a text within the bounding box of an image (width-wise at least) without the Freetype library? GD- or ImageMagick-specifc code would do nicely. -- -Lost...
1
by: J.J.Cale | last post by:
The following code works partially. If Justify is set to 0, I see 3 separate lines of text left justified but when I try to right or center justify I only get the first line. It is justified...
2
by: neovantage | last post by:
Hey all, I have created transparent PNG images from text dynamically. But it edges are pixel-ate or we can say edges are distorted. Here is my LINK which shows my generated transparent PNG image....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.