1 package Imager::Font::BBox;
6 Imager::Font::BBox - objects representing the bounding box of a string.
13 my $font = Imager::Font->new(...);
14 my $bbox = $font->bounding_box(string=>$text, size=>$size);
17 my $start = $bbox->start_offset;
18 my $end = $bbox->end_offset;
19 my $gdescent = $box->global_descent;
20 my $gascent = $bbox->global_ascent;
21 my $ascent = $bbox->ascent;
22 my $decent = $bbox->descent;
23 my $total_width = $bbox->total_width;
24 my $fheight = $bbox->font_height;
25 my $theight = $bbox->text_height;
29 Objects of this class are returned by the Imager::Font bounding_box()
30 method when it is called in scalar context.
32 This will hopefully make the information from this method more
41 Returns the horizonatal offset from the selected drawing location to
42 the left edge of the first character drawn. If this is positive, the
43 first glyph is to the right of the drawing location.
45 The alias neg_width() is present to match the bounding_box()
46 documentation for list context.
60 The offset from the selected drawing location to the right edge of the
61 last character drawn. Should always be positive.
63 You can use the alias pos_width() if you are used to the
64 bounding_box() documentation for list context.
76 =item global_descent()
78 The lowest position relative to the font baseline that any character
79 in the font reaches in the character cell. Normally negative.
81 At least one font we've seen has reported a positive number for this.
91 The highest position relative to the font baseline that any character
92 in the font reaches in the character cell. Normally positive.
102 The lowest position relative to the font baseline that any character
103 in the supplied string reaches. Negative when any character's glyph
104 reaches below the baseline.
114 The highest position relative to the font baseline that any character
115 in the supplied string reaches. Positive if any character's glyph
116 reaches above the baseline.
124 =item advance_width()
126 The advance width of the string, if the driver supports that,
127 otherwise the same as end_offset.
134 @$self > 6 ? $self->[6] : $self->[2];
139 The total displayed width of the string.
146 $self->end_offset - $self->start_offset;
151 The maximum displayed height of any string using this font.
157 $self->global_ascent - $self->global_descent;
162 The displayed height of the supplied string.
169 $self->ascent - $self->descent;
174 =head1 INTERNAL FUNCTIONS
180 Called by Imager::Font->bounding_box() to create the object.
186 return bless [ @_ ], $class;
193 Doesn't reproduce the functionality that you get using the x and y
194 parameters to Imager::Font->bounding_box(). I considered:
196 my ($left, $top, $right, $bottom) = $box->offset(x=>$x, y=>$y)
198 but this is about as clumsy as the original.
202 Tony Cook <tony@develop-help.com>
206 Imager(3), Imager::Font(3)