GD::Text::Wrap.3pm
上传用户:qdrechuli
上传日期:2022-08-01
资源大小:917k
文件大小:9k
- ." Automatically generated by Pod::Man version 1.15
- ." Tue Oct 8 11:46:53 2002
- ."
- ." Standard preamble:
- ." ======================================================================
- .de Sh " Subsection heading
- .br
- .if t .Sp
- .ne 5
- .PP
- fB\$1fR
- .PP
- ..
- .de Sp " Vertical space (when we can't use .PP)
- .if t .sp .5v
- .if n .sp
- ..
- .de Ip " List item
- .br
- .ie \n(.$>=3 .ne \$3
- .el .ne 3
- .IP "\$1" \$2
- ..
- .de Vb " Begin verbatim text
- .ft CW
- .nf
- .ne \$1
- ..
- .de Ve " End verbatim text
- .ft R
- .fi
- ..
- ." Set up some character translations and predefined strings. *(-- will
- ." give an unbreakable dash, *(PI will give pi, *(L" will give a left
- ." double quote, and *(R" will give a right double quote. | will give a
- ." real vertical bar. *(C+ will give a nicer C++. Capital omega is used
- ." to do unbreakable dashes and therefore won't be available. *(C` and
- ." *(C' expand to `' in nroff, nothing in troff, for use with C<>
- .tr (*W-|(bv*(Tr
- .ds C+ Cv'-.1v'h'-1p's-2+h'-1p'+s0v'.1v'h'-1p'
- .ie n {
- . ds -- (*W-
- . ds PI pi
- . if (n(.H=4u)&(1m=24u) .ds -- (*Wh'-12u'(*Wh'-12u'-" diablo 10 pitch
- . if (n(.H=4u)&(1m=20u) .ds -- (*Wh'-12u'(*Wh'-8u'-" diablo 12 pitch
- . ds L" ""
- . ds R" ""
- . ds C` ""
- . ds C' ""
- 'br}
- .el{
- . ds -- |(em|
- . ds PI (*p
- . ds L" ``
- . ds R" ''
- 'br}
- ."
- ." If the F register is turned on, we'll generate index entries on stderr
- ." for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
- ." index entries marked with X<> in POD. Of course, you'll have to process
- ." the output yourself in some meaningful fashion.
- .if nF {
- . de IX
- . tm Index:\$1t\n%t"\$2"
- ..
- . nr % 0
- . rr F
- .}
- ."
- ." For nroff, turn off justification. Always turn off hyphenation; it
- ." makes way too many mistakes in technical documents.
- .hy 0
- .if n .na
- ."
- ." Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
- ." Fear. Run. Save yourself. No user-serviceable parts.
- .bd B 3
- . " fudge factors for nroff and troff
- .if n {
- . ds #H 0
- . ds #V .8m
- . ds #F .3m
- . ds #[ f1
- . ds #] fP
- .}
- .if t {
- . ds #H ((1u-(\\n(.fu%2u))*.13m)
- . ds #V .6m
- . ds #F 0
- . ds #[ &
- . ds #] &
- .}
- . " simple accents for nroff and troff
- .if n {
- . ds ' &
- . ds ` &
- . ds ^ &
- . ds , &
- . ds ~ ~
- . ds /
- .}
- .if t {
- . ds ' \k:h'-(\n(.wu*8/10-*(#H)''h"|\n:u"
- . ds ` \k:h'-(\n(.wu*8/10-*(#H)'`h'|\n:u'
- . ds ^ \k:h'-(\n(.wu*10/11-*(#H)'^h'|\n:u'
- . ds , \k:h'-(\n(.wu*8/10)',h'|\n:u'
- . ds ~ \k:h'-(\n(.wu-*(#H-.1m)'~h'|\n:u'
- . ds / \k:h'-(\n(.wu*8/10-*(#H)'z(slh'|\n:u'
- .}
- . " troff and (daisy-wheel) nroff accents
- .ds : \k:h'-(\n(.wu*8/10-*(#H+.1m+*(#F)'v'-*(#V'z.h'.2m+*(#F'.h'|\n:u'v'*(#V'
- .ds 8 h'*(#H'(*bh'-*(#H'
- .ds o \k:h'-(\n(.wu+w'(de'u-*(#H)/2u'v'-.3n'*(#[z(dev'.3n'h'|\n:u'*(#]
- .ds d- h'*(#H'(pdh'-w'~'u'v'-.25m'f2(hyfPv'.25m'h'-*(#H'
- .ds D- D\k:h'-w'D'u'v'-.11m'z(hyv'.11m'h'|\n:u'
- .ds th *(#[v'.3m's+1Is-1v'-.3m'h'-(w'I'u*2/3)'s-1os+1*(#]
- .ds Th *(#[s+2Is-2h'-w'I'u*3/5'v'-.3m'ov'.3m'*(#]
- .ds ae ah'-(w'a'u*4/10)'e
- .ds Ae Ah'-(w'A'u*4/10)'E
- . " corrections for vroff
- .if v .ds ~ \k:h'-(\n(.wu*9/10-*(#H)'s-2u~ds+2h'|\n:u'
- .if v .ds ^ \k:h'-(\n(.wu*10/11-*(#H)'v'-.4m'^v'.4m'h'|\n:u'
- . " for low resolution devices (crt and lpr)
- .if n(.H>23 .if n(.V>19
- {
- . ds : e
- . ds 8 ss
- . ds o a
- . ds d- dh'-1'(ga
- . ds D- Dh'-1'(hy
- . ds th o'bp'
- . ds Th o'LP'
- . ds ae ae
- . ds Ae AE
- .}
- .rm #[ #] #H #V #F C
- ." ======================================================================
- ."
- .IX Title "Text::Wrap 3"
- .TH Text::Wrap 3 "perl v5.6.1" "2000-09-18" "User Contributed Perl Documentation"
- .UC
- .SH "NAME"
- &s-1GD:s0:Text::Wrap - Wrap strings in boxes
- .SH "SYNOPSIS"
- .IX Header "SYNOPSIS"
- .Vb 2
- & use GD;
- & use GD::Text::Wrap;
- .Ve
- .Vb 2
- & my $gd = GD::Image->new(800,600);
- & # allocate colours, do other things.
- .Ve
- .Vb 5
- & my $text = <<EOSTR;
- & Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
- & sed diam nonummy nibh euismod tincidunt ut laoreet dolore
- & magna aliquam erat volutpat.
- & EOSTR
- .Ve
- .Vb 9
- & my $wrapbox = GDTextWrap->new( $gd,
- & line_space => 4,
- & color => $black,
- & text => $text,
- & );
- & $wrapbox->set_font(gdMediumBoldFont);
- & $wrapbox->set_font('cetus.ttf', 12);
- & $wrapbox->set(align => 'left', width => 120);
- & $wrapbox->draw(10,140);
- .Ve
- .Vb 1
- & $gd->rectangle($wrap_box->get_bounds(10,140), $color);
- .Ve
- .SH "DESCRIPTION"
- .IX Header "DESCRIPTION"
- &s-1GD:s0:Text::Wrap provides an object that draws a formatted paragraph of
- text in a box on a s-1GD:s0:Image canvas, using either a builtin s-1GDs0 font
- or a TrueType font.
- .SH "METHODS"
- .IX Header "METHODS"
- This class doesn't inherit from s-1GD:s0:Text directly, but delegates most of
- its work to it (in fact to a s-1GD:s0:Text::Align object. That means that
- most of the s-1GD:s0:Text::Align methods are available for this class,
- specifically f(CW*(C`set_font*(C'fR and f(CW*(C`font_path*(C'fR. Other methods and methods
- with a different interface are described here:
- .Sh "s-1GD:s0:Text::Wrap->new( f(CW$gd_objectfP, attribute => value, ... )"
- .IX Subsection "GD::Text::Wrap->new( $gd_object, attribute => value, ... )"
- Create a new object. The first argument to new has to be a valid
- &s-1GD:s0:Image object. The other arguments will be passed to the fIset()fR method
- for initialisation of the attributes.
- .Sh "$wrapbox->set( attribute => value, ... )"
- .IX Subsection "$wrapbox->set( attribute => value, ... )"
- set the value for an attribute. Valid attributes are:
- .Ip "width" 4
- .IX Item "width"
- The width of the box to draw the text in. If unspecified, they will
- default to the width of the s-1GD:s0:Image object.
- .Ip "line_space" 4
- .IX Item "line_space"
- The number of pixels between lines. Defaults to 2.
- .Ip "para_space, paragraph_space" 4
- .IX Item "para_space, paragraph_space"
- The number of extra pixels between paragraphs, above line_space.
- Defaults to 0.
- .Ip "color, colour" 4
- .IX Item "color, colour"
- Synonyms. The colour to use when drawing the font. Will be initialised
- to the last colour in the s-1GDs0 object's palette.
- .Ip "align, alignment" 4
- .IX Item "align, alignment"
- Synonyms. One of 'justified' (the default), 'left', 'right' or 'center'.
- .Ip "text" 4
- .IX Item "text"
- The text to draw. This is the only attribute that you absolutely have to
- set.
- .Ip "preserve_nl" 4
- .IX Item "preserve_nl"
- If set to a true value, newlines in the text will cause a line break.
- Note that lines will still be justified. If only one word appears on
- the line, it could get ugly.
- Defaults to 0.
- .PP
- As with the methods, attributes unknown to this class get delegated to
- the s-1GD:s0:Text::Align class.
- .Sh "$wrapbox->get( attribute );"
- .IX Subsection "$wrapbox->get( attribute );"
- Get the current value of an attribute. All attributes mentioned under
- the f(CW*(C`set()*(C'fR method can be retrieved
- .Sh "$wrapbox->fIget_bounds()fP"
- .IX Subsection "$wrapbox->get_bounds()"
- Returns the bounding box of the box that will be drawn with the current
- attribute settings as a list. The values returned are the coordinates of
- the upper left and lower right corner.
- .PP
- .Vb 1
- & ($left, $top, $right, $bottom) = $wrapbox->get_bounds();
- .Ve
- Returns an empty list on error.
- .PP
- &s-1NOTE:s0 The return list of this method may change in a future
- implementation that allows angled boxes.
- .Sh "$wrapbox->draw(x, y)"
- .IX Subsection "$wrapbox->draw(x, y)"
- Draw the box, with (x,y) as the top right corner.
- Returns the same values as the f(CW*(C`getbounds()*(C'fR method.
- .PP
- &s-1NOTE:s0 The return list of this method may change in a future
- implementation that allows angled boxes.
- .SH "NOTES"
- .IX Header "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 may get burned. I may change them at any time.
- .PP
- You can only use TrueType fonts with version of s-1GDs0 > 1.20, and then
- only if compiled with support for this. If you attempt to do it
- anyway, you will get errors.
- .PP
- Even though this module lives in the s-1GD:s0:Text namespace, it is not a
- &s-1GD:s0:Text. It does however delegate a lot of its functionality to a
- contained object that is one (s-1GD:s0:Text::Align).
- .SH "BUGS"
- .IX Header "BUGS"
- None that I know of, but that doesn't mean much. There may be some
- problems with exotic fonts, or locales and character encodings that I am
- not used to.
- .SH "TODO"
- .IX Header "TODO"
- Angled boxes.
- .PP
- At the moment, the only bit of the box that is allowed to be unspecified
- and in fact must be unspecified, is the bottom. If there is enough need
- for it, I might implement more flexibility, in that that you need to
- only specify three of the four sides of the box, and the fourth will
- be calculated.
- .PP
- Automatic resizing of a TrueType font to fit inside a box when four
- sides are specified, or maybe some other nifty things.
- .PP
- More flexibility in the interface. Especially draw needs some thought.
- .PP
- More and better error handling.
- .PP
- Warnings for lines that are too long and stick out of the box.
- Warning for emptyish lines?
- .SH "COPYRIGHT"
- .IX Header "COPYRIGHT"
- copyright 1999
- Martien Verbruggen (mgjv@comdyn.com.au)
- .SH "SEE ALSO"
- .IX Header "SEE ALSO"
- the GD manpage, the GD::Text manpage, the GD::Text::Align manpage