I am trying to insert a variable $font1
below. The variable $font1
is the name of the font e.g. arial. I really want it to return $arial
(or whatever $font
is) as a variable.
When $arial
is called, it gets the arial.ttf from a folder on my server via get_fonts.pl.
I have tried everything \$$font
'"$font"'
and every possible variation of that.
I even tried if ($font=="arial"){$font = a ton of different attempts;}
do "get_fonts.pl";
&GetFonts($im);
foreach $key (keys %ENV) {
if($key !~ /[A-Z]/){
if ($key="sometext") {
$text="$ENV{'typetext'}";
$color="$ENV{'typecolor'}";
$font="$ENV{'typefont'}";
$size="$ENV{'typesize'}";
$string = qq~ $text ~;
$gd_text = GD::Text->new() or die GD::Text::error();
$gd_text->set_font($arialb, $size) or die $gd_text->error;
$gd_text->set_text($string);
my ($w, $h) = $gd_text->get('width', 'height');
$y1 = (300 / 6);
if ($w <= 380) {
$x1 = ((400 / 2) - ($w / 2));
$im->stringFT("$blue", $font1, $size, 0, $x1, $y1, "$string");
}
...
Pay no attention to excluded ending brackets..
Notice whare I called $font1
.. If I call $arialb
all is fine.
Here is get fonts
sub GetFonts {
my($im) = $_[0];
$arial = "fonts/arial.ttf";
# I tried Tons of things here to no avail
if ($font=="arialb") {
$font1 = '$arialb'; # and so many different other attempts
}
$arialb = "fonts/ariblk.ttf";
$ariali = "fonts/ariali.ttf";
$arialbi = "fonts/arialbi.ttf";
$comic = "fonts/comic.ttf";
$comicb = "fonts/comicbd.ttf";
$verdana = "fonts/verdana.ttf";
$verdanab = "fonts/verdanab.ttf";
$verdanai = "fonts/verdanai.ttf";
$verdanabi = "fonts/verdanaz.ttf";
}
I also desire to do the same with $color
but, once $font
is figured out, I should be able to fiqure that out.
Thanks for any help.