Bug 197747 - gdImageStringFT sets improper bounding box for rendered text
Summary: gdImageStringFT sets improper bounding box for rendered text
Alias: None
Product: Fedora
Classification: Fedora
Component: gd   
(Show other bugs)
Version: 5
Hardware: All Linux
Target Milestone: ---
Assignee: Ivana Varekova
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2006-07-05 22:21 UTC by Joel Uckelman
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2006-11-21 09:14:03 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
program for generating pngs (711 bytes, text/x-c++src)
2006-07-05 22:21 UTC, Joel Uckelman
no flags Details
example of the problem (5.98 KB, image/png)
2006-07-05 22:25 UTC, Joel Uckelman
no flags Details
program for generating pngs with rotated text (1.21 KB, text/x-c++src)
2006-07-21 15:38 UTC, Joel Uckelman
no flags Details

Description Joel Uckelman 2006-07-05 22:21:53 UTC
Created attachment 131967 [details]
program for generating pngs

Comment 1 Joel Uckelman 2006-07-05 22:21:53 UTC
Description of problem:

gdImageStringFT() sets the bounding box for text to be rendered. Unfortunately,
the bounding box it calculates extends too far to the right (by an amount which
seems to depend on the font size). This makes it difficult center text
horizontally, since the text itself is not centered within the calculated
bounding box.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Call gdImageStringFT to get a bounding box for some text.
2. Find the center of the BB.
3. Call gdImageStringFT to paint the text, offset by half of the BB width.
Actual results:

Text is several pixels too far to the left.

Expected results:

Text should be centered horizontally.

Additional info:

I'm attaching a little example program and a png generated by it which exhibits
the problem. At most sizes, the text is too far left by at least two pixels.

Comment 2 Joel Uckelman 2006-07-05 22:25:57 UTC
Created attachment 131969 [details]
example of the problem

The bounding box extends 3 pixels too far to the right of the period. This is
not so problematic for lengthy text, but extremely annoying for short text and
a disaster for rotated text.

Comment 3 Jitka Kozana 2006-07-20 10:54:11 UTC
Can you please send me program, which generates pictures with rotated text and 
has the wrong bounding? Thank you.

Comment 4 Joel Uckelman 2006-07-21 15:38:26 UTC
Created attachment 132819 [details]
program for generating pngs with rotated text

Usage: rotate fontsize angle text >foo.png

The problem is easy to see if you make the size 24 and the angle 60, with some
short bit of text that has descenders (e.g., "Test string"). It appears that
the text is being painted into the lower-left corner (relative to the text) of
the bounding box.

Comment 5 Jitka Kozana 2006-07-24 11:56:21 UTC
Ok, thank you for the test program. 
I wanted to make sure I know, what you your problem is.

Comment 6 Ivana Varekova 2006-11-21 09:14:03 UTC
Fixed in gd-2.0.33-11.fc7.

Note You need to log in before you can comment on or make changes to this bug.