The following test works fine with ActiveState (build 623, their GD ver 1.27.2].
My guess is you are trying to print characters that aren't
defined in the font you are specifying, except that doesn't
seem likely with simple numbers. Anyway, there is nothing
fancy about the string, to answer that part of the question.
use strict;
use warnings;
use GD;
my $im = new GD::Image(150,60);
my $white = $im->colorAllocate(255,255,255); # UPDATE without this th
+e background
# will be the same as th
+e text colour
my $blue = $im->colorAllocate(0,0,255); # might as well allocate this
+ too while I'm at it...
my @bounds = $im->stringTTF($blue,'c:/i386/Arial.ttf',22,0,0,36,'123 J
+aPh!');
if (!@bounds) {print "TTF error: $@\n";}
print join ':', @bounds;
open OUT, '>foo.jpg' or die "Couldn't open output: $!";
binmode OUT;
print OUT $im->jpeg;
close OUT;
Update: Aargh you're
correct! I actually did test this
but as part of a larger script which had already set some
colours. I've corrected the above code as marked (thanks!). And for the record
this was under NT4. I'll have to try it on a Win9x box sometime.
--
I'd like to be able to assign to an luser
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.