tests failed with old patch (111_sav...)
because empty option-font was
passed in tests. now working.

fixed patch attached.

31, 32, 39 failed before and after patching:
 

t/31_ocropus.t ................. 1/? Using ocroscript with recognize.
tesslanguage=eng ocroscript recognize test.png

#   Failed test 'Ocropus returned sensible text'
#   at t/31_ocropus.t line 32.
#                   '<!DOCTYPE html
#     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
#     http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
# <html xmlns="http://www.w3.org/1999/xhtml";><head><meta content="ocr_line 
ocr_page" name="ocr-capabilities"/><meta content="en" name="ocr-langs"/><meta 
content="Latn" name="ocr-scripts"/><meta content="" name="ocr-
microformats"/><title>OCR Output</title></head>
# <body><div class="ocr_page" title="bbox 0 0 450 58; image test.png"><span 
class="ocr_line" title="bbox 8 11 449 57">The- quick brown fox
# </span></div></body></html>
# '
#     doesn't match '(?-xism:The quick brown fox)'
# Looks like you failed 1 test of 2.
t/31_ocropus.t ................. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests



t/32_ocropus_in_thread.t ....... 1/2 Using ocroscript with recognize.
Getting info for test.png
Format Portable Network Graphics
New page filename test.png, format Portable Network Graphics
Added /tmp/7xDAZbRAcgb.png at page 1 with resolution 300
Using ocroscript with recognize.
tesslanguage=eng ocroscript recognize /tmp/7xDAZbRAcgb.png
unlink0: /tmp/7xDAZbRAcgb.png is gone already at 
/usr/share/perl5/Gtk2/Ex/Simple/TiedCommon.pm line 65
t/32_ocropus_in_thread.t ....... 2/2
#   Failed test 'Ocropus returned sensible text'
#   at t/32_ocropus_in_thread.t line 43.
#                   '<!DOCTYPE html
#     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
#     http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
# <html xmlns="http://www.w3.org/1999/xhtml";><head><meta content="ocr_line 
ocr_page" name="ocr-capabilities"/><meta content="en" name="ocr-langs"/><meta 
content="Latn" name="ocr-scripts"/><meta content="" name="ocr-
microformats"/><title>OCR Output</title></head>
# <body><div class="ocr_page" title="bbox 0 0 450 58; image 
/tmp/7xDAZbRAcgb.png"><span class="ocr_line" title="bbox 8 11 449 57">The- 
quick brown fox
# </span></div></body></html>
# '
#     doesn't match '(?-xism:The quick brown fox)'
# Looks like you failed 1 test of 2.
t/32_ocropus_in_thread.t ....... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests


t/39_gocr.t .................... Getting info for test.pnm
Format Portable anymap
New page filename test.pnm, format Portable anymap
Added /tmp/UISp1CHodSo.pnm at page 1 with resolution 72
gocr /tmp/UISp1CHodSo.pnm
unlink0: /tmp/UISp1CHodSo.pnm is gone already at 
/usr/share/perl5/Gtk2/Ex/Simple/TiedCommon.pm line 65
t/39_gocr.t .................... 1/1
#   Failed test 'gocr returned sensible text'
#   at t/39_gocr.t line 42.
#                   'TJ7e quic_ brown fox
# '
#     doesn't match '(?-xism:The quick brown fox)'
# Looks like you failed 1 test of 1.
t/39_gocr.t .................... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests

--- Gscan2pdf.pm	2011-08-27 07:00:41.000000000 +0200
+++ Gscan2pdf.pm	2011-10-24 09:23:48.959012706 +0200
@@ -434,12 +434,18 @@
  my ( $self, $path, $list_of_pages, $metadata, $options, $pidfile ) = @_;
 
  my $page = 0;
+ my %fonthash = ();
 
  # Create PDF with PDF::API2
  $self->{message} = $d->get('Setting up PDF');
  my $pdf = PDF::API2->new( -file => $path );
  $pdf->info($metadata) if defined($metadata);
 
+ if( defined( $options->{font} ) ){ 
+   $fonthash{ $options->{font} } = $pdf->ttfont( $options->{font}, -unicodemap => 1 );
+ }
+ $fonthash{ 'Times-Roman' } = $pdf->corefont('Times-Roman');
+
  foreach my $pagedata ( @{$list_of_pages} ) {
   ++$page;
   $self->{progress} = $page / ( $#{$list_of_pages} + 2 );
@@ -578,10 +584,10 @@
    for my $box ( $pagedata->boxes ) {
     my ( $x1, $y1, $x2, $y2, $txt ) = @$box;
     if ( $txt =~ /[[:^ascii:]]/ and defined( $options->{font} ) ) {
-     $font = $pdf->ttfont( $options->{font}, -unicodemap => 1 );
+     $font = $fonthash{ $options->{font} };
     }
     else {
-     $font = $pdf->corefont('Times-Roman');
+     $font = $fonthash{'Times-Roman'};
     }
     ( $x2, $y2 ) = ( $w * $resolution, $h * $resolution )
       if ( $x1 == 0 and $y1 == 0 and not defined($x2) );

Reply via email to