Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

gd 2.46 usefontconfig can i look at it without changing its value?

by Anonymous Monk
on Dec 28, 2012 at 17:21 UTC ( #1010721=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If you have support for fontconfig font patterns, calling $image->useFontConfig(0); seems to turn it on, although the docs suggest that only $image->useFontConfig(1); turns it on. Is this a bug? I would like to test if its available with +out turning it on. In the code below (which prints 1 on my computer), Expected - Error because 'AlgerianD' isn't a font path Got - Fontconfig has been switched on, so 'AlgerianD' works, and the p +ath given to stringFT is matched with Arial or whatever it finds (?). use strict; use warnings; use GD; use File::Slurp; my $self = {}; $self->{img} = new GD::Image(64, 64); $self->{colourhash} = {rect => '000fff', line => '000000'}; setdefaultcolours($self); $self->{img}->filledRectangle(0, 0, 64, 64, $self->{colours}->{rect}); print $self->{img}->useFontConfig(0), "\n"; $self->{img}->stringFT($self->{colours}->{line}, '/home/dan/.fonts/ALG +ERINN.TTF', 20, 0, 32, 32, chr(68)) or die $@; $self->{img}->stringFT($self->{colours}->{line}, 'AlgerianD', 20, 0, 5 +, 32, chr(68)) or die $@; create($self, 'out.png'); sub create { my ($self, $out) = @_; write_file($out, {binmode => ':raw'}, $self->{img}->png) or die "Can +'t open $out\n"; } sub setdefaultcolours { my $self = shift; while (my ($key, $value) = each %{$self->{colourhash}}) { $self->{colours}->{$key} = setcolour($self, $key, $value); } } sub setcolour { my ($self, $colour, $value) = @_; my @a = map { hex $_ } $value =~ /(..)/g; if (defined $value) { $self->{colours}->{$colour} = $self->{img}->colorAllocate(@a); $self->{colourhash}->{$colour} = $value; } return $self->{colours}->{$colour} }
  • Comment on gd 2.46 usefontconfig can i look at it without changing its value?
  • Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010721]
Approved by kennethk
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-08-19 21:35 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (312 votes). Check out past polls.