use strict;
use vars qw($VERSION);
-$VERSION = sprintf "%d.%03d", q$Revision$=~/\d+/g;
+$VERSION = "1.033";
# the aim here is that we can:
# - add file based types in one place: here
class=>'Imager::Font::Truetype',
module=>'Imager/Font/Truetype.pm',
files=>'.*\.ttf$',
+ description => 'FreeType 1.x',
},
t1=>{
class=>'Imager::Font::Type1',
module=>'Imager/Font/Type1.pm',
files=>'.*\.pfb$',
+ description => 'T1Lib',
},
ft2=>{
class=>'Imager::Font::FreeType2',
module=>'Imager/Font/FreeType2.pm',
files=>'.*\.(pfa|pfb|otf|ttf|fon|fnt|dfont|pcf(\.gz)?)$',
+ description => 'FreeType 2.x',
},
ifs=>{
class=>'Imager::Font::Image',
w32=>{
class=>'Imager::Font::Win32',
module=>'Imager/Font/Win32.pm',
+ description => 'Win32 GDI Fonts',
},
);
# this function is called from Imager.pm to finish initialization
sub __init {
@priority = grep Imager::i_has_format($_), @priority;
- delete @drivers{grep !Imager::i_has_format($_), keys %drivers};
+ for my $driver_name (grep Imager::i_has_format($_), keys %drivers) {
+ $drivers{$driver_name}{enabled} = 1;
+ }
}
# search method
}
$type = $hsh{'type'};
- if (!defined($type) or !$drivers{$type}) {
+ if (!defined($type) or !$drivers{$type} or !$drivers{$type}{enabled}) {
for my $drv (@priority) {
undef $type;
my $re = $drivers{$drv}{files} or next;
}
}
if (!defined($type)) {
- $Imager::ERRSTR = "Font type not found";
+ # some types we can support, but the driver isn't available
+ # work out which drivers support it, so we can provide the user
+ # some useful information on how to get it working
+ my @not_here;
+ for my $driver_name (keys %drivers) {
+ my $driver = $drivers{$driver_name};
+ push @not_here, "$driver_name ($driver->{description})"
+ if $driver->{files} && $file =~ /$driver->{files}/i;
+ }
+ if (@not_here) {
+ $Imager::ERRSTR = "No font drivers enabled that can support this file, rebuild Imager with any of ".join(", ", @not_here)." to use this font file";
+ }
+ else {
+ $Imager::ERRSTR = "No font type found for $hsh{'file'}";
+ }
return;
}
} elsif ($hsh{face}) {
aa - the default value for the $im->string(...) C<aa> parameter.
Default: 0.
+=item *
+
+index - for font file containing multiple fonts this selects which
+font to use. This is useful for Macintosh DFON (.dfont) and suitcase
+font files.
+
+If you want to use a suitcase font you will need to tell Imager to use
+the FreeType 2.x driver by setting C<type> to C<'ft2'>:
+
+ my $font = Imager::Font->new(file=>$file, index => 1, type=>'ft2')
+ or die Imager->errstr;
+
=back
+
+
=item bounding_box
Returns the bounding box for the specified string. Example:
Both Freetype 1.x and 2.x allow support for glyph names to not be
included.
+=item draw
+
+This is used by Imager's string() method to implement drawing text.
+See L<Imager::Draw/string>.
+
=back
=head1 MULTIPLE MASTER FONTS
your font doesn't support it, Imager will I<not> build it from 0041
"LATIN CAPITAL LETTER A" and 0308 "COMBINING DIAERESIS".
+To check if a driver supports UTF8 call the utf8 method:
+
+=over
+
+=item utf8
+
+Return true if the font supports UTF8.
+
+=back
+
=head2 Native UTF8 Support
If your version of perl supports UTF8 and the driver supports UTF8,
list is used to choose which one should be used, if a given format can
be handled by more than one driver.
-The current priority can be retrieved with:
+=over
+
+=item priorities
+
+The current priorities can be retrieved with:
@drivers = Imager::Font->priorities();
@old = Imager::Font->priorities(@drivers);
+=back
+
If you supply driver names that are not currently supported, they will
be ignored.