php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #295 GD1.3/TTF Feature request
Submitted: 1998-04-21 15:30 UTC Modified: 1998-07-06 06:35 UTC
From: cmv at privateworld dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0 Latest CVS OS: Linux 2.0.27 Slackware
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cmv at privateworld dot com
New email:
PHP Version: OS:

 

 [1998-04-21 15:30 UTC] cmv at privateworld dot com
It has been noted that the TTF text function is of 
limited use because, once you've created the text you 
want, there is no way to access the "bounding box" of 
the generated text (so you could crop your image down 
to size, for example).

A cursory look at gdttf.c seems to show that everytime 
a glyph is generated and added to the final image, the 
function "knows" what the bounding box of the current 
glyph is.

I don't know C, but imagine that adding some kind of 
tracking mechanism on a glyph by glyph basis could be 
used to provide the bounding box of the entire image.

For example (pseudo-code):

set overallbox to null;
for each glyph {
  calculate the bounding box of the glyph -> glyphbox;
  generate the glyph;
  compare the glyphbox to the overallbox ->
  if (glyphbox.min_x < overallbox.min_x) {
    overallbox.min_x = glyphbox.min_x; }
  if (glyphbox.min_y < overallbox.min_y) {
    overallbox.min_y = glyphbox.min_y; }
  if (glyphbox.max_x > overallbox.max_x) {
    overallbox.max_x = glyphbox.max_x; }
  if (glyphbox.max_y > overallbox.max_y) {
    overallbox.max_y = glyphbox.max_y; }
}


Then, make the values of the overall boundingbox 
availble, through a PHP function like:
   $array = ImageTTFBoundingBox();

Anyone up for the challenge?  ;)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-07-06 06:35 UTC] ssb
part of 3.0.1

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 14:01:26 2024 UTC