|  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
 [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?  ;)


Add a Patch

Pull Requests

Add a Pull Request


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: Thu Apr 18 21:01:29 2024 UTC