Imager::Font::BBox - objects representing the bounding box of a string. |
Imager::Font::BBox - objects representing the bounding box of a string.
use Imager::Font;
# get the object my $font = Imager::Font->new(...); my $bbox = $font->bounding_box(string=>$text, size=>$size);
# methods my $start = $bbox->start_offset; my $left_bearing = $bbox->left_bearing; my $right_bearing = $bbox->right_bearing; my $end = $bbox->end_offset; my $gdescent = $box->global_descent; my $gascent = $bbox->global_ascent; my $ascent = $bbox->ascent; my $decent = $bbox->descent; my $total_width = $bbox->total_width; my $fheight = $bbox->font_height; my $theight = $bbox->text_height; my $display_width = $bbox->display_width;
Objects of this class are returned by the Imager::Font bounding_box()
method when it is called in scalar context.
This will hopefully make the information from this method more accessible.
start_offset()
The alias neg_width()
is present to match the bounding_box()
documentation for list context.
The alias left_bearing()
is present to match font terminology.
advance_width()
If the glyph overflows the right side of the advance width this value is negative.
Equals advance_width - left_bearing - right_bearing (and implemented that way.)
global_descent()
At least one font we've seen has reported a positive number for this.
global_ascent()
descent()
ascent()
font_height()
text_height()
These methods include bugs kept for backwards compatibility and shouldn't be used in new code.
total_width()
New code should use display_width().
This depends on end_offset(), and is limited by it's backward compatibility.
You can use the alias pos_width()
if you are used to the
bounding_box()
documentation for list context.
For backwards compatibility this method returns the maximum of the advance width and the offset of the right edge of the last glyph.
new(...)
bounding_box()
to create the object.
Doesn't reproduce the functionality that you get using the x and y parameters to Imager::Font->bounding_box(). I considered:
my ($left, $top, $right, $bottom) = $box->offset(x=>$x, y=>$y)
but this is about as clumsy as the original.
Tony Cook <tony@develop-help.com>
Imager(3), Imager::Font(3)
Imager::Font::BBox - objects representing the bounding box of a string. |