suche nach in der

imagepsencodefont> <imagepolygon
Last updated: Fri, 18 May 2012

view this page in

imagepsbbox

(PHP 4, PHP 5)

imagepsbbox Ermittelt die Ausmaße des Rechtecks, das für die Ausgabe eines Textes unter Verwendung eines PostScript-Fonts (Typ 1) notwendig ist.

Beschreibung:

array imagepsbbox ( string $text , int $font , int $size [, int $space [, int $tightness [, float $angle ]]] )

Size ist die Größe in Pixel.

Space ermöglicht ihnen, den vorgegebenen Wert für den Zeichen-Zwischenraum eines Fonts anzugeben. Dieser Wert wird zum Normal-Wert hinzu gezählt und kann auch negativ sein.

Tightness ermöglicht ihnen die Kontrolle über die Breite eines Leerzeichens. Der angegebene Wert wird zur normalen Zeichenbreite hinzu gezählt und kann auch negativ sein.

Angle (Winkel) wird in Grad angegeben und beinhaltet den Drehungswinkel des auszugebenden Textes.

Die Parameter space und tightness haben als Einheit die Zeichenbreite, wobei der Wert 1 gleich 1/1000stel der Breite des Zeichens 'm' entspricht (Maß 'em').

Die Parameter space, tightness und angle sind optional.

Das umgebende Rechteck wird berechnet unter Verwendung der für die Zeichen-Abmessungen verfügbaren Informationen und unterscheidet sich immer etwas von den aktuellen Raster-Werten des Textes. Ist der Winkel (angle) mit 0 angegeben, können Sie davon ausgehen, dass der Text in jede Richtung immer 1 Pixel mehr braucht als sonst.

Diese Funktion gibt ein Array zurück, welches die folgenden Elemente enthält:

0 untere linke x-Koordinate
1 untere linke y-Koordinate
2 obere rechte x-Koordinate
3 obere rechte y-Koordinate

Siehe auch imagepstext().



add a note add a note User Contributed Notes
imagepsbbox
honza dot bartos at gmail dot com
23-Oct-2006 11:25
When using imagepsbbox, keep in mind, that meaning of y-coordinates is slightly different here. Y-coordinates returned by this function are related to the baseline of the text starting at point [0,0]. Positive values represent points ABOVE the baseline, negative values represent points BELOW the baseline. That is why the lower left y-coordinate is always smaller here than the upper right y-coordinate (these two coordinates are actualy values of metrics.descent and metrics.ascent - see T1Lib docs).

So when you want to place some text using coordinates of the top left corner (for example [100,100]), use this:

<?php

$x
= 100;
$y = 100;
$text = "Dodge this";
$fontsize=18;
$font=imagepsloadfont("somefont.pfb");
list(
$lx,$ly,$rx,$ry) = imagepsbbox($text,$font,$fontsize);
imagepstext ($someimage, $text, $font, $fontsize, $somecolor, $somecolor, $x, $y + $ry);

?>

Hope it helps someone, I got stuck with this for a while.
daniel at dantec dot NO_SPAM dot nl
18-Apr-2002 06:23
When using imagepsbbox, you are probably trying to do something like creating a button with text, so that the button is large enough for the text...
Below is a very simple example of making a black button just big enough to display white text on it.

<?php

//if text is no variable set sample text
if (!$text)
   
$text = "This is a sample text";
   
// set the font size
$fontsize=14;

// load the font to use
$font=ImagePsLoadFont("/fonts/ariam___.pfb");

//get the left lower corner and the right upper
list($lx,$ly,$rx,$ry) = imagepsbbox($text,$font,$fontsize,0,0,0);

// calculate the size of the text
$textwidth = $rx - $lx;
$textheight = $ry - $ly;

// make an image 40 pixels wider and 20 pixels higher than the text
$imh = $textheight + 20;
$imw = $textwidth + 40;
$im = imageCreate( $imw, $imh );

//define colors, first color is used as background color!
$black  = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);

//create the text (with the same parameters as imagepsbbox!)
ImagePSText ($im, "$text", $font, $fontsize, $white, $white, 20, 20,'','','',4);

//send the header
header("Content-type: image/jpeg");

// create the image
ImageJPEG ($im,"",100);

//destroy the image & font to free memory
Imagepsfreefont ( $font );
ImageDestroy ( $im );

?>

imagepsencodefont> <imagepolygon
Last updated: Fri, 18 May 2012