Bug 197747 - gdImageStringFT sets improper bounding box for rendered text
gdImageStringFT sets improper bounding box for rendered text
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: gd (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ivana Varekova
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-07-05 18:21 EDT by Joel Uckelman
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-11-21 04:14:03 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
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 18:21 EDT, Joel Uckelman
no flags Details
example of the problem (5.98 KB, image/png)
2006-07-05 18:25 EDT, Joel Uckelman
no flags Details
program for generating pngs with rotated text (1.21 KB, text/x-c++src)
2006-07-21 11:38 EDT, Joel Uckelman
no flags Details

  None (edit)
Description Joel Uckelman 2006-07-05 18:21:53 EDT
Created attachment 131967 [details]
program for generating pngs
Comment 1 Joel Uckelman 2006-07-05 18:21:53 EDT
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):

gd-2.0.33-6.2

How reproducible:

Always

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 18:25:57 EDT
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 06:54:11 EDT
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 11:38:26 EDT
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 07:56:21 EDT
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 04:14:03 EST
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.