imageftbbox

(PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8)

imageftbboxGive the bounding box of a text using fonts via freetype2

Beschreibung

imageftbbox(
    float $size,
    float $angle,
    string $font_filename,
    string $string,
    array $options = []
): array|false

This function calculates and returns the bounding box in pixels for a FreeType text.

Hinweis:

Prior to PHP 8.0.0, imageftbbox() was an extended variant of imagettfbbox() which additionally supported the options. As of PHP 8.0.0, imagettfbbox() is an alias of imageftbbox().

Parameter-Liste

size

Die Schriftgröße in Punkten.

angle

Angle in degrees in which string will be measured.

font_filename

The name of the TrueType font file (can be a URL). Depending on which version of the GD library that PHP is using, it may attempt to search for files that do not begin with a leading '/' by appending '.ttf' to the filename and searching along a library-defined font path.

string

The string to be measured.

options

Possible array indexes for options
Key Type Meaning
linespacing float Defines drawing linespacing

Rückgabewerte

imageftbbox() returns an array with 8 elements representing four points making the bounding box of the text:

0 lower left corner, X position
1 lower left corner, Y position
2 lower right corner, X position
3 lower right corner, Y position
4 upper right corner, X position
5 upper right corner, Y position
6 upper left corner, X position
7 upper left corner, Y position

The points are relative to the text regardless of the angle, so "upper left" means in the top left-hand corner seeing the text horizontally.

On failure, false is returned.

Beispiele

Beispiel #1 imageftbbox() example

<?php
// Create a 300x150 image
$im imagecreatetruecolor(300150);
$black imagecolorallocate($im000);
$white imagecolorallocate($im255255255);

// Set the background to be white
imagefilledrectangle($im00299299$white);

// Path to our font file
$font './arial.ttf';

// First we create our bounding box
$bbox imageftbbox(100$font'The PHP Documentation Group');

// This is our cordinates for X and Y
$x $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 5;
$y $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5;

imagefttext($im100$x$y$black$font'The PHP Documentation Group');

// Output to browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
?>

Anmerkungen

Hinweis: Diese Funktion ist nur verfügbar wenn PHP mit Freetype unterstützung (--with-freetype-dir=DIR) kompiliert wurde

Siehe auch

  • imagefttext() - Write text to the image using fonts using FreeType 2
  • imagettfbbox() - Ermittle das umgebende Rechteck eines Textes unter Verwendung von True-Type Schriftarten

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Definition von Stored Procedures - eine Einführung

Stored Procedures sind vordefinierte SQL-Codeblöcke, die in einer Datenbank gespeichert sind und bei Bedarf aufgerufen werden können. ...

Bernie

Autor : ebiz-consult GmbH & Co. KG
Kategorie: mySQL-Tutorials

Wie kann man komplexe Abfragen mit SQL-Querys In MySQLi effektiv durchführen?

In diesem MySQL-Tutorial wird erklärt, wie komplexe SQL-Abfragen in MySQLi effizient durchgeführt werden können. Wir werden uns mit verschiedenen Aspekten der Datenbankabfrage beschäftigen und spezifische Methoden kennenlernen. ...

TheMax

Autor : TheMax
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Professioneller Webentwickler & Webdesigner

Of course, here is the translation: Hello, Thank you for your interest in the long-term project. Your extensive skills and experience in web dev ...

Geschrieben von Athelstan am 15.04.2024 09:25:39
Forum: Jobgesuche
Wir stellen unsere SEO-Agentur vor

Hallo In der heutigen digitalen Welt war es für Unternehmen noch nie so einfach, ihre Reichweite weltweit zu vergrößern. Wenn Sie außerhalb I ...

Geschrieben von thomasmuller am 14.04.2024 07:18:33
Forum: User stellen sich vor
Spielplan für 4 Gruppen zu je 6 Teams auf 2 Feldern

Hallöchen zusammen, ich versuche derzeit unseren Excel-Spielplan in PHP zu überführen. Eigentlich bin ich auch shon fertig - wenn da nicht dies ...

Geschrieben von derH0st am 11.04.2024 15:58:37
Forum: PHP Developer Forum
PHP 8.3.3 - App kann auf dem PC nicht ausgeführt werden

Problem gelöst. Die php.exe hatte einen defekt. Neue heruntergeladen und fertig.

Geschrieben von Tetra1081 am 10.04.2024 16:49:14
Forum: PHP Developer Forum