Imager::DTP::Textbox

Imager::DTP::Textbox is a multi-byte text handling module with text wrapping and line alignment, for use with Imager.
Download

Imager::DTP::Textbox Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Toshimasa Ishibashi
  • Publisher web site:
  • http://search.cpan.org/~bashi/Imager-DTP-0.06/lib/Imager/DTP/Letter.pm

Imager::DTP::Textbox Tags


Imager::DTP::Textbox Description

Imager::DTP::Textbox is a multi-byte text handling module with text wrapping and line alignment, for use with Imager. Imager::DTP::Textbox is a multi-byte text handling module with text wrapping and line alignment, for use with Imager.SYNOPSIS use Imager::DTP::Textbox::Horizontal; # or Vertical # first, define font & text string my $font = Imager::Font->new(file=>'path/to/foo.ttf',type=>'ft2', size=>14,color=>'#000000',aa=>1); my $text = 'The Greater Of Two Evils'; # create instance my $tb = Imager::DTP::Textbox::Horizontal->new( text=>$text,font=>$font); # draw the text string on target image my $target = Imager->new(xsize=>250,ysize=>250); $target->box(filled=>1,color=>'#FFFFFF'); # with white background $tb->draw(target=>$target,x=>10,y=>10); # and write out image to file $target->write(file=>'result.jpg',type=>'jpeg');Imager::DTP::Textbox is a module intended for handling sentences and paragraphs consisted with multi-byte characters, such as Japanese and Chinese. It supports text wrapping and line alignment, and is able to draw text string vertically from top to bottom as well. All the text string provided (by setText() method) will be splitted by "n", and each chunk will be turned into Imager::DTP::Line instance internally. So in another words, Imager::DTP::Textbox can be described as "a big box to put lines and letters in order". It's like WWW Browser's textarea input, or Adobe Illustrator's textbox tool. # creating instance - basic way my $tb = Imager::DTP::Textbox::Horizontal->new(); $tb->setText(text=>$text,font=>$font); # set text with font $tb->setWspace(pixel=>5); # set space between letters $tb->setLeading(percent=>180); # set space between lines $tb->setAlign(halign=>'left',valign=>'top'); # set text alignment $tb->setWrap(width=>200,height=>150); # set text wrapping $tb->setLetterScale(x=>1.2,y=>0.5); # set letter transform scale # creating instance - or the shorcut way my $tb = Imager::DTP::Textbox::Horizontal->new( text=>$text, # set text font=>$font, # set font wspace=>5, # set word distance (pixels) leading=>150, # set line distance (percent) halign=>'left', # set horizontal alignment valign=>'top', # set vertical alignment wrapWidth=>200, # set text wrap width wrapHeight=>180, # set text wrap height xscale=>1.5, # set letter transformation x scale yscale=>0.5, # set letter transformation y scale ); Requirements: · Perl


Imager::DTP::Textbox Related Software