Bug 197747

Summary: gdImageStringFT sets improper bounding box for rendered text
Product: [Fedora] Fedora Reporter: Joel Uckelman <uckelman>
Component: gdAssignee: Ivana Varekova <varekova>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-11-21 09:14:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
program for generating pngs
none
example of the problem
none
program for generating pngs with rotated text none

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):

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 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.