======[PHP] Font Image Creator Single Entry======
Dieses Script wendet die Classe FontImageCreator an um eine Textgrafik aus einem PHP-Link mit Parametern zusammenstellen kann.
=====Benötigte Module=====
* [[FontClass]]
====Code====
=====font.php=====
(php;1;font.php)
textColor = $color;
}
if (preg_match(C_COLOR_PATTERN, $color ='#'.$backgroundColor)){
$font->backgroundColor = $color;
$font->transparent = false;
}
if ($size) $font->size = $size;
if ($border) $font->border = $border;
if ($transparent) $font->transparent = $transparent;
if ($angle) $font->angle = $angle;
if ($fontPath) $font->fontPath = $fontPath;
// create the image
$font->createPng();
// clean up
$font=NULL;
unset($font);
} catch (Exception $e){
echo nl2br("{$e->getMessage()}\n");
echo nl2br($e);
}
?>
=====Verwendung mit Pfadumleitung=====
Wenn man die Grafik in einem Forum oder so als Signatur verwenden will, kann man dies mittels Rewrite umgehen. Dazu müssen wir in der .htaccess-Datei ensprechende Regeln definieren. Mein Beispiel beinhalter 3 verchiedene Regeln
#Rewrite Engine einschalten
RewriteEngine on
#nur Pfade umleiten die keine Datei sind
RewriteCond %{REQUEST_FILENAME} !-f
#nur Pfade umleiten die kein Ordner sind
RewriteCond %{REQUEST_FILENAME} !-d
# alles an meine Datei weiterleiten. Von da kann man dan machen was man will...
#Schema: path/$font/[$textColor/[$backgroundColor/]]$text[/img.png]
#Beispiel: path/arial.ttf/00FFFF/FFFF00/Hallo+Welt
#rewrite: path/font.php?font=arial.ttf&textColor=00FFFF&backgroundColor=FFFF00&text=Hallo+Welt
#Beispiel: path/arial.ttf/00FFFF/Hallo+Welt/img.png
#rewrite: path/font.php?font=arial.ttf&textColor=00FFFF&text=Hallo+Welt
#Beispiel: path/arial.ttf/Hallo+Welt/img.png
#rewrite: path/font.php?font=arial.ttf&text=Hallo+Welt
RewriteRule ^([^\/]+)\/(?:([[:xdigit:]]{6})\/|)(?:([[:xdigit:]]{6})\/|)(?:(.*(?=\/img.png))|(.*)) font.php?font=$1&textColor=$2&backgroundColor=$3&text=$4$5 [L,QSA]
=====Verlinkung auf Webseite=====
Um die Grafik auf einer Webseite anzuzeigen kann sie genaus verlinkt werden wie jede andere Grafik