#!/usr/local/bin/perl # Change above line to path to your perl binary ##---------------------------------------------------------------------------## ## Author: ## Pradeep Padala, ppadala@cise.ufl.edu ## Description: ## TTF Fonts example ##---------------------------------------------------------------------------## ## Copyright (C) 2002 Pradeep Padala, ppadala@cise.ufl.edu ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA ##---------------------------------------------------------------------------## use GD; do "init_colors.pl"; # Create a new image $im = new GD::Image(270, 80); # Allocate some colors &InitColors($im); # Make the background transparent and interlaced $im->transparent($white); $im->interlaced('true'); $im->rectangle(0, 0, 269, 79, $black); $x1 = 10; $y1 = 20; # Draw text in a TTF font $font = "/usr/X11R6/lib/X11/fonts/TTF/luxisri.ttf"; $im->stringFT($red, $font, 15, 0, $x1, $y1, "A TTF font"); $anotherfont = "/usr/share/fonts/default/TrueType/starbats.ttf"; $im->stringFT($blue, $font, 20, 0, $x1, $y1 + 40, "Another one here !!!"); # Open a file for writing open(PICTURE, ">picture.png") or die("Cannot open file for writing"); # Make sure we are writing to a binary stream binmode PICTURE; # Convert the image to PNG and print it to the file PICTURE print PICTURE $im->png; close PICTURE;