Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1010721]
Approved by kennethk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (15)
As of 2015-07-31 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls