]> git.imager.perl.org - imager.git/commitdiff
- the FT 1.x was comparing versus an uninitialized variable when
authorTony Cook <tony@develop=help.com>
Thu, 21 Apr 2005 14:58:55 +0000 (14:58 +0000)
committerTony Cook <tony@develop=help.com>
Thu, 21 Apr 2005 14:58:55 +0000 (14:58 +0000)
  checking the end of string when calculating the right side bearing
  used to adjust pos_width for glyphs that overlap the right side of the
  advance width.

Changes
TODO
font.c
lib/Imager/Font.pm
t/t35ttfont.t
t/t38ft2font.t

diff --git a/Changes b/Changes
index 34d375c7f08dd5d4fbd7b56d408aa83d17b773ed..fde12b6b257c5b24922b2f0953f4f112048e54a0 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1062,6 +1062,10 @@ Revision history for Perl extension Imager.
 - Imager::Font::BBox advance_width() method was falling back to
   the wrong value when the font driver's low level function
   didn't return the advance width.
+- the FT 1.x was comparing versus an uninitialized variable when
+  checking the end of string when calculating the right side bearing
+  used to adjust pos_width for glyphs that overlap the right side of the
+  advance width.
 
 =================================================================
 
diff --git a/TODO b/TODO
index 565977306d960bc66c332fd0d59867bd96562cc5..be5b839fc6ff49aa5e2ef8c54bda3f7fba4b8eee 100644 (file)
--- a/TODO
+++ b/TODO
@@ -16,7 +16,8 @@ not commitments.
   caching.  If FT1 is faster, add caching as a TODO for FT2.
 - add XS for i_tags_get_string() and test it.
 - test and fix problem with fallback value for 
-  Imager::Font::BBox->advance_width.
+  Imager::Font::BBox->advance_width. (done)
+- i_tt_bbox_inst in font.c uses variable i without ever setting it.
 - add sample CGI that handles an uploaded image (done)
 - examples for fountain filter in Imager::Filters
 - allow Imager::Fountain to take color descriptions (eg. blue, FF000)
diff --git a/font.c b/font.c
index 7b5d0931f3a5bc9fe149fdc73b2ebc2dd9156c6b..5099ee2e7d57245b803050b64421b3b59200ea5d 100644 (file)
--- a/font.c
+++ b/font.c
@@ -1664,7 +1664,7 @@ Function to get texts bounding boxes given the instance of the font (internal)
 static
 undef_int
 i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, int len, int cords[BOUNDING_BOX_COUNT], int utf8 ) {
-  int i, upm, casc, cdesc, first;
+  int upm, casc, cdesc, first;
   
   int start    = 0;
   int width    = 0;
@@ -1717,7 +1717,7 @@ i_tt_bbox_inst( TT_Fonthandle *handle, int inst ,const char *txt, int len, int c
        descent  = (gm->bbox.yMin-63) / 64;
        first = 0;
       }
-      if (i == len-1) {
+      if (!len) { /* if at end of string */
        /* the right-side bearing - in case the right-side of a 
           character goes past the right of the advance width,
           as is common for italic fonts
index 3f374b6bf2e436f56ec777e17f6e54f1757f0261..3fa10ad204200acf82c9e6e99794beba1b8f685e 100644 (file)
@@ -325,7 +325,8 @@ Imager::Font - Font handling for Imager.
    $pos_width,
    $global_ascent,
    $descent,
-   $ascent) = $font->bounding_box(string=>"Foo");
+   $ascent,
+   $advance_width) = $font->bounding_box(string=>"Foo");
 
   $logo = $font->logo(text   => "Slartibartfast Enterprises",
                      size   => 40,
index c74240e78aa358b4a27828b1f737bc97e3fe6bf2..133d0302d86d44257b8aa5c79ded8843b2710e3f 100644 (file)
@@ -1,7 +1,7 @@
 #!perl -w
 use strict;
 use lib 't';
-use Test::More tests => 40;
+use Test::More tests => 43;
 
 BEGIN { use_ok(Imager => ':all') }
 require "t/testtools.pl";
@@ -119,7 +119,7 @@ SKIP:
  SKIP:
   {
     ok($hcfont, "loading existence test font")
-      or skip("could not load test font", 11);
+      or skip("could not load test font", 14);
 
     # list interface
     my @exists = $hcfont->has_chars(string=>'!A');
@@ -147,6 +147,14 @@ SKIP:
     
     print "# ** name table of the test font **\n";
     Imager::i_tt_dump_names($hcfont->{id});
+
+    # the test font is known to have a shorter advance width for that char
+    my @bbox = $hcfont->bounding_box(string=>"/", size=>100);
+    is(@bbox, 7, "should be 7 entries");
+    isnt($bbox[6], $bbox[2], "different advance width from pos width");
+    print "# @bbox\n";
+    my $bbox = $hcfont->bounding_box(string=>"/", size=>100);
+    isnt($bbox->pos_width, $bbox->advance_width, "OO check");
   }
   undef $hcfont;
   
index 9f4947930a8ba0f884e5306b6c5e2f0d7dfc9f87..b659be0a7cc800d4553e108ecf5a64756a5de777 100644 (file)
@@ -237,7 +237,7 @@ if (okx($exfont, "loaded existence font")) {
   # the test font is known to have a shorter advance width for that char
   my @bbox = $exfont->bounding_box(string=>"/", size=>100);
   okx(@bbox == 7, "should be 7 entries");
-  okx($bbox[6] != $bbox[4], "different advance width");
+  okx($bbox[6] != $bbox[2], "different advance width");
   my $bbox = $exfont->bounding_box(string=>"/", size=>100);
   okx($bbox->pos_width != $bbox->advance_width, "OO check");