1Imager::Font::BBox(3) User Contributed Perl DocumentationImager::Font::BBox(3)
2
3
4

NAME

6       Imager::Font::BBox - objects representing the bounding box of a string.
7

SYNOPSIS

9         use Imager::Font;
10
11         # get the object
12         my $font = Imager::Font->new(...);
13         my $bbox = $font->bounding_box(string=>$text, size=>$size);
14
15         # methods
16         my $start = $bbox->start_offset;
17         my $left_bearing = $bbox->left_bearing;
18         my $right_bearing = $bbox->right_bearing;
19         my $end = $bbox->end_offset;
20         my $gdescent = $box->global_descent;
21         my $gascent = $bbox->global_ascent;
22         my $ascent = $bbox->ascent;
23         my $decent = $bbox->descent;
24         my $total_width = $bbox->total_width;
25         my $fheight = $bbox->font_height;
26         my $theight = $bbox->text_height;
27         my $display_width = $bbox->display_width;
28

DESCRIPTION

30       Objects of this class are returned by the Imager::Font bounding_box()
31       method when it is called in scalar context.
32
33       This will hopefully make the information from this method more
34       accessible.
35

METHODS

37       start_offset()
38       neg_width
39       left_bearing
40           Returns the horizontal offset from the selected drawing location to
41           the left edge of the first character drawn.  If this is positive,
42           the first glyph is to the right of the drawing location.
43
44           The alias neg_width() is present to match the bounding_box()
45           documentation for list context.
46
47           The alias left_bearing() is present to match font terminology.
48
49       advance_width()
50           The advance width of the string, if the driver supports that,
51           otherwise the same as end_offset.
52
53       right_bearing
54           The distance from the right of the last glyph to the end of the
55           advance point.
56
57           If the glyph overflows the right side of the advance width this
58           value is negative.
59
60       display_width
61           The distance from the left-most pixel of the left-most glyph to the
62           right-most pixel of the right-most glyph.
63
64           Equals advance_width - left_bearing - right_bearing (and
65           implemented that way.)
66
67       global_descent()
68           The lowest position relative to the font baseline that any
69           character in the font reaches in the character cell.  Normally
70           negative.
71
72           At least one font we've seen has reported a positive number for
73           this.
74
75       global_ascent()
76           The highest position relative to the font baseline that any
77           character in the font reaches in the character cell.  Normally
78           positive.
79
80       descent()
81           The lowest position relative to the font baseline that any
82           character in the supplied string reaches.  Negative when any
83           character's glyph reaches below the baseline.
84
85       ascent()
86           The highest position relative to the font baseline that any
87           character in the supplied string reaches.  Positive if any
88           character's glyph reaches above the baseline.
89
90       font_height()
91           The maximum displayed height of any string using this font.
92
93       text_height()
94           The displayed height of the supplied string.
95

OBSOLETE METHODS

97       These methods include bugs kept for backwards compatibility and
98       shouldn't be used in new code.
99
100       total_width()
101           The total displayed width of the string.
102
103           New code should use display_width().
104
105           This depends on end_offset(), and is limited by it's backward
106           compatibility.
107
108       end_offset
109       pos_width
110           The offset from the selected drawing location to the right edge of
111           the last character drawn.  Should always be positive.
112
113           You can use the alias pos_width() if you are used to the
114           bounding_box() documentation for list context.
115
116           For backwards compatibility this method returns the maximum of the
117           advance width and the offset of the right edge of the last glyph.
118

INTERNAL FUNCTIONS

120       new(...)
121           Called by Imager::Font->bounding_box() to create the object.
122

BUGS

124       Doesn't reproduce the functionality that you get using the x and y
125       parameters to Imager::Font->bounding_box().  I considered:
126
127         my ($left, $top, $right, $bottom) = $box->offset(x=>$x, y=>$y)
128
129       but this is about as clumsy as the original.
130

AUTHOR

132       Tony Cook <tony@develop-help.com>
133

SEE ALSO

135       Imager(3), Imager::Font(3)
136
137
138
139perl v5.32.1                      2021-01-27             Imager::Font::BBox(3)
Impressum