PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|GD|Text.pm =

page 1 of 7



# $Id: Text.pm,v 1.37 2003/06/19 00:13:10 mgjv Exp $

package GD::Text;

($GD::Text::prog_version) = '$Revision: 1.37 $' =~ /\s([\d.]+)/;
$GD::Text::VERSION = '0.86';

=head1 NAME

GD::Text - Text utilities for use with GD

=head1 SYNOPSIS

  use GD;
  use GD::Text;

  my $gd_text = GD::Text->new() or die GD::Text::error();
  $gd_text->set_font('funny.ttf', 12) or die $gd_text->error;
  $gd_text->set_font(gdTinyFont);
  $gd_text->set_font(GD::Font::Tiny);
  ...
  $gd_text->set_text($string);
  my ($w, $h) = $gd_text->get('width', 'height');

  if ($gd_text->is_ttf)
  {
      ...
  }

Or alternatively

  my $gd_text = GD::Text->new(
        text => 'Some text',
        font => 'funny.ttf',
        ptsize => 14,
    );

=head1 DESCRIPTION

This module provides a font-independent way of dealing with text in
GD, for use with the GD::Text::* modules and GD::Graph.

=head1 NOTES

As with all Modules for Perl: Please stick to using the interface. If
you try to fiddle too much with knowledge of the internals of this
module, you could get burned. I may change them at any time.

You can only use TrueType fonts with version of GD > 1.20, and then
only if compiled with support for this. If you attempt to do it
anyway, you will get errors.

If you want to refer to builtin GD fonts by their short name
(C<gdTinyFont>, C<gdGiantFont>), you will need to C<use> the GD module
as well as one the GD::Text modules, because it is GD that exports
those names into your name space. If you don't like that, use the
longer alternatives (C<GD::Font->Giant>) instead.

=head1 METHODS

=cut

use strict;

use GD;
use Carp;
use Cwd;

use vars qw($FONT_PATH @FONT_PATH $OS);
BEGIN
{
    $FONT_PATH = $ENV{FONT_PATH}     || 
                 $ENV{TTF_FONT_PATH} ||
                 $ENV{TT_FONT_PATH}  || '';
    unless ($OS = $^O)
    {
        require Config;
        $OS = $Config::Config{'os_name'};
    }
}

my $ERROR;

=head2 GD::Text->new( attrib => value, ... )

Create a new object. See the C<set()> method for attributes.

=cut

sub new
{
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self = { 
            type   => 'builtin',
            font   => gdSmallFont,
            ptsize => 10,
        };
    bless $self => $class;
    $self->set(@_) or return;
=1=

= PAGE 1 = NEXT > |2|3|4|5|6|7

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.00531316 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)