]> git.imager.perl.org - imager.git/blobdiff - lib/Imager/Font/BBox.pm
eliminate use vars
[imager.git] / lib / Imager / Font / BBox.pm
index dd58f7ab760b85af741de869f008158d21edef34..579378a83e290d56103023614df4d371ca02bd65 100644 (file)
@@ -1,6 +1,9 @@
 package Imager::Font::BBox;
 package Imager::Font::BBox;
+use 5.006;
 use strict;
 
 use strict;
 
+our $VERSION = "1.007";
+
 =head1 NAME
 
 Imager::Font::BBox - objects representing the bounding box of a string.
 =head1 NAME
 
 Imager::Font::BBox - objects representing the bounding box of a string.
@@ -41,7 +44,11 @@ accessible.
 
 =item start_offset()
 
 
 =item start_offset()
 
-Returns the horizonatal offset from the selected drawing location to
+=item neg_width
+
+=item left_bearing
+
+Returns the horizontal offset from the selected drawing location to
 the left edge of the first character drawn.  If this is positive, the
 first glyph is to the right of the drawing location.
 
 the left edge of the first character drawn.  If this is positive, the
 first glyph is to the right of the drawing location.
 
@@ -64,22 +71,53 @@ sub left_bearing {
   return $_[0][0];
 }
 
   return $_[0][0];
 }
 
-=item end_offset()
+=item advance_width()
 
 
-The offset from the selected drawing location to the right edge of the
-last character drawn.  Should always be positive.
+The advance width of the string, if the driver supports that,
+otherwise the same as end_offset.
 
 
-You can use the alias pos_width() if you are used to the
-bounding_box() documentation for list context.
+=cut
+
+sub advance_width {
+  my $self = shift;
+
+  @$self > 6 ? $self->[6] : $self->[2];
+}
+
+=item right_bearing
+
+The distance from the right of the last glyph to the end of the advance
+point.
+
+If the glyph overflows the right side of the advance width this value
+is negative.
 
 =cut
 
 
 =cut
 
-sub end_offset {
-  return $_[0][2];
+sub right_bearing {
+  my $self = shift;
+
+  @$self >= 8 && return $self->[7]; # driver gives it to us
+
+  # otherwise the closest we have is the difference between the 
+  # end_pos and advance_width
+  return $self->advance_width - $self->pos_width;
 }
 
 }
 
-sub pos_width {
-  return $_[0][2];
+=item display_width
+
+The distance from the left-most pixel of the left-most glyph to the
+right-most pixel of the right-most glyph.
+
+Equals advance_width - left_bearing - right_bearing (and implemented
+that way.)
+
+=cut
+
+sub display_width {
+  my ($self) = @_;
+
+  $self->advance_width - $self->left_bearing - $self->right_bearing;
 }
 
 =item global_descent()
 }
 
 =item global_descent()
@@ -130,31 +168,6 @@ sub ascent {
   return $_[0][5];
 }
 
   return $_[0][5];
 }
 
-=item advance_width()
-
-The advance width of the string, if the driver supports that,
-otherwise the same as end_offset.
-
-=cut
-
-sub advance_width {
-  my $self = shift;
-
-  @$self > 6 ? $self->[6] : $self->[2];
-}
-
-=item total_width()
-
-The total displayed width of the string.
-
-=cut
-
-sub total_width {
-  my $self = shift;
-
-  $self->end_offset - $self->start_offset;
-}
-
 =item font_height()
 
 The maximum displayed height of any string using this font.
 =item font_height()
 
 The maximum displayed height of any string using this font.
@@ -178,40 +191,53 @@ sub text_height {
   $self->ascent - $self->descent;
 }
 
   $self->ascent - $self->descent;
 }
 
-=item right_bearing
+=back
 
 
-The distance from the right of the last glyph to the end of the advance
-point.
+=head1 OBSOLETE METHODS
 
 
-If the glyph overflows the right side of the advance width this value
-is negative.
+These methods include bugs kept for backwards compatibility and
+shouldn't be used in new code.
+
+=over
+
+=item total_width()
+
+The total displayed width of the string.
+
+New code should use display_width().
+
+This depends on end_offset(), and is limited by it's backward
+compatibility.
 
 =cut
 
 
 =cut
 
-sub right_bearing {
+sub total_width {
   my $self = shift;
 
   my $self = shift;
 
-  @$self >= 8 && return $self->[7]; # driver gives it to us
-
-  # otherwise the closest we have is the difference between the 
-  # end_pos and advance_width
-  return $self->advance_width - $self->pos_width;
+  $self->end_offset - $self->start_offset;
 }
 
 }
 
-=item display_width
+=item end_offset
 
 
-The distance from the left-most pixel of the left-most glyph to the
-right-most pixel of the right-most glyph.
+=item pos_width
 
 
-Equals advance_width - left_bearing - right_bearing (and implemented
-that way.)
+The offset from the selected drawing location to the right edge of the
+last character drawn.  Should always be positive.
+
+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.
 
 =cut
 
 
 =cut
 
-sub display_width {
-  my ($self) = @_;
+sub end_offset {
+  return $_[0][2];
+}
 
 
-  $self->advance_width - $self->left_bearing - $self->right_bearing;
+sub pos_width {
+  return $_[0][2];
 }
 
 =back
 }
 
 =back