ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
custom fonts on "signs", PHP, 2nd step (Cyrillic) (Wishlist)
custom fonts on "signs", PHP, 2nd step (Cyrillic) // WishlistananasMar 29, 2001, 9:59pm
The previous version had some trouble, it was cached sometimes(?) - but
this one looks MUCH better and works : <?PHP Header ("Content-type: image/jpeg"); $im = imagecreate (256,256); $tmp = $HTTP_GET_VARS["tc"]; // text color if (empty ($tmp)) $r = $g = $b = 0xff; else { $r = hexdec (substr ($tmp, 0, 2)); $g = hexdec (substr ($tmp, 2, 2)); $b = hexdec (substr ($tmp, 4, 2)); } $fore = ImageColorAllocate ($im, $r, $g, $b); $tmp = $HTTP_GET_VARS["bc"]; // background color if (empty ($tmp)) $r = $g = $b = 0x00; else { $r = hexdec (substr ($tmp, 0, 2)); $g = hexdec (substr ($tmp, 2, 2)); $b = hexdec (substr ($tmp, 4, 2)); } $back = ImageColorAllocate ($im, $r, $g, $b); imagefill ($im, 1, 1, $back); $size = $HTTP_GET_VARS["s"]; // size if ($size == 0) $size = 10; $list = explode("|", $HTTP_GET_VARS["t"]); // text $pos = $size / 1.5; foreach ($list as $line) { $line = strtr ($line, "^", " "); ImageTTFText ($im, $size, 0, 0, $pos, $fore, "symbol.ttf", $line); $pos = $pos + $size; } ImageJPEG ($im); ImageDestroy ($im); ?> Copy this script to any folder on your server, I used "oct31.de/fonts/cyr.php" Copy the character set "symbol.ttf" from your \windows\font folder to the same folder on the server. Off course any other TTF file can be used, it is referenced only in one line of the script and can easily be changed. ====== USAGE ====== Create a zpict2.rwx with : create picture oct31.de/fonts/cyr.php?s=50&bc=d06060&tc=0020ff&t=HELLO|WORLD||and^some|more^text The script takes 4 arguments : - the font size in pixels s=50 - the background color in hex bc=d06060 - the text color tc=0020ff - the text to be written t=HELLO|WORLD||and^some|more^text The text uses dashes ^ instead of space characters and pipes | instead of newline characters. The default for the colors is black and white Default size is 10 pixels ananasMar 29, 2001, 10:22pm
This is a multi-part message in MIME format.
--------------A72227F5AD61F9D5E494552A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit just in case it is Greek letters and not Cyrillic - I'm not familiar with fonts - but while I play with it - hm, looks more greek than cyrillic --------------A72227F5AD61F9D5E494552A Content-Type: text/x-vcard; charset=us-ascii; name="vha.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Volker Hatzenberger Content-Disposition: attachment; filename="vha.vcf" begin:vcard n:Hatzenberger;Volker x-mozilla-html:FALSE url:oct31.de adr:;;Bornheimer Strasse 15;Bonn;;53111;Germany version:2.1 email;internet:vha at oct31.de end:vcard --------------A72227F5AD61F9D5E494552A-- ananasMar 29, 2001, 11:39pm
This is a multi-part message in MIME format.
--------------44C42870E4C3A6CB4C8A6A0F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit good source for truetype fonts that can be used : http://babel.uoregon.edu/yamada/fonts.html [View Quote] begin:vcard n:Hatzenberger;Volker x-mozilla-html:FALSE url:oct31.de adr:;;Bornheimer Strasse 15;Bonn;;53111;Germany version:2.1 email;internet:vha at oct31.de end:vcard --------------44C42870E4C3A6CB4C8A6A0F-- |