File: W32.pm

package info (click to toggle)
libimager-perl 1.005%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,308 kB
  • ctags: 4,067
  • sloc: perl: 30,915; ansic: 27,680; makefile: 55; cpp: 4
file content (103 lines) | stat: -rw-r--r-- 1,918 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package Imager::Font::W32;
use strict;
use Imager;
use vars qw($VERSION @ISA);
@ISA = qw(Imager::Font);

BEGIN {
  $VERSION = "0.89";

  require XSLoader;
  XSLoader::load('Imager::Font::W32', $VERSION);
}

# called by Imager::Font::new()
# since Win32's HFONTs include the size information this
# is just a stub
sub new {
  my $class = shift;
  my %opts =
      (
       color => Imager::Color->new(255, 0, 0),
       size => 15,
       @_,
      );

  return bless \%opts, $class;
}

sub _bounding_box {
  my ($self, %opts) = @_;
  
  my @bbox = i_wf_bbox($self->{face}, $opts{size}, $opts{string}, $opts{utf8});
  unless (@bbox) {
    Imager->_set_error(Imager->_error_as_msg);
    return;
  }

  return @bbox;
}

sub _draw {
  my $self = shift;

  my %input = @_;
  if (exists $input{channel}) {
    return i_wf_cp($self->{face}, $input{image}{IMG}, $input{x}, $input{'y'},
	    $input{channel}, $input{size},
	    $input{string}, $input{align}, $input{aa}, $input{utf8});
  }
  else {
    return i_wf_text($self->{face}, $input{image}{IMG}, $input{x}, 
	      $input{'y'}, $input{color}, $input{size}, 
	      $input{string}, $input{align}, $input{aa}, $input{utf8});
  }
}


sub utf8 {
  return 1;
}

sub can_glyph_names {
  return;
}

1;

__END__

=head1 NAME

Imager::Font::W32 - font support using C<GDI> on Win32

=head1 SYNOPSIS

  use Imager;

  my $img = Imager->new;
  my $font = Imager::Font->new(face => "Arial", type => "w32");

  $img->string(... font => $font);

=head1 DESCRIPTION

This provides font support on Win32.

=head1 CAVEATS

Unfortunately, older versions of Imager would install
Imager::Font::Win32 even if Win32 wasn't available, and if no font was
created would succeed in loading the module.  This means that an
existing Win32.pm could cause a probe success for Win32 fonts, so I've
renamed it.

=head1 AUTHOR

Tony Cook <tonyc@cpan.org>

=head1 SEE ALSO

Imager, Imager::Font.

=cut