From 8b40a4ed26cc25a8a8644eec650f44d929144986 Mon Sep 17 00:00:00 2001
From: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Date: Thu, 10 Apr 2014 10:53:26 -0300
Subject: [PATCH] Bug 12068 - label-create-pdf.pl Add support for RTL language
On top of Bug 8375
If you print a label using arabic/hebrew script,
letters are printed in logical direction, from left
to right, giving a mangled result
This patch will try to fix those cases adding a new
perl dependency, Text::Bidi, and using the automagic
feature if it's log2vis() function to rearrange chars
based on detected text 'direction'
To test:
1. Install Text::Bidi package
(apt-get install libtext-bidi-perl)
2. Try a batch, using Helvetica, with a mix of
ltr and rtl (arabic/hebrew) titles, chars are good,
but direction is bad
3. Apply the patch
4. Try again, now the result is good
Formerly a followup of Bug 8375, look sample pics
on that Bug.
Rebased following changes on Bug 8375
Note: Arabic titles will not be displayed, because
current code selects Oblique variant. But Hebrew
looks good.
---
C4/Installer/PerlDependencies.pm | 5 +++++
install_misc/debian.packages | 1 +
install_misc/ubuntu.10.04.packages | 1 +
install_misc/ubuntu.12.04.packages | 1 +
install_misc/ubuntu.packages | 1 +
labels/label-create-pdf.pl | 4 +++-
6 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm
index 2bea1c6..905c531 100644
--- a/C4/Installer/PerlDependencies.pm
+++ b/C4/Installer/PerlDependencies.pm
@@ -699,6 +699,11 @@ our $PERL_DEPS = {
'required' => '0',
'min_ver' => '0.73',
},
+ 'Text::Bidi' => {
+ 'usage' => 'Label batch PDF',
+ 'required' => '0',
+ 'min_ver' => '0.03',
+ },
};
1;
diff --git a/install_misc/debian.packages b/install_misc/debian.packages
index 9c31206..9b8ad6d 100644
--- a/install_misc/debian.packages
+++ b/install_misc/debian.packages
@@ -107,6 +107,7 @@ libtest-mockmodule-perl install
libtest-strict-perl install
libtest-warn-perl install
libtest-yaml-valid-perl install
+libtext-bidi-perl install
libtext-charwidth-perl install
libtext-csv-encoded-perl install
libtext-csv-perl install
diff --git a/install_misc/ubuntu.10.04.packages b/install_misc/ubuntu.10.04.packages
index 17cfdc8..d849d6a 100644
--- a/install_misc/ubuntu.10.04.packages
+++ b/install_misc/ubuntu.10.04.packages
@@ -134,6 +134,7 @@ libtest-mockmodule-perl install
libtest-strict-perl install
libtest-warn-perl install
libtest-yaml-valid-perl install
+libtext-bidi-perl install
libtext-charwidth-perl install
libtext-csv-encoded-perl install
libtext-csv-perl install
diff --git a/install_misc/ubuntu.12.04.packages b/install_misc/ubuntu.12.04.packages
index c63aaf3..8a535f0 100644
--- a/install_misc/ubuntu.12.04.packages
+++ b/install_misc/ubuntu.12.04.packages
@@ -139,6 +139,7 @@ libtest-mockmodule-perl install
libtest-strict-perl install
libtest-warn-perl install
libtest-yaml-valid-perl install
+libtext-bidi-perl install
libtext-charwidth-perl install
libtext-csv-encoded-perl install
libtext-csv-perl install
diff --git a/install_misc/ubuntu.packages b/install_misc/ubuntu.packages
index aea298e..ff132c9 100644
--- a/install_misc/ubuntu.packages
+++ b/install_misc/ubuntu.packages
@@ -139,6 +139,7 @@ libtest-mockmodule-perl install
libtest-strict-perl install
libtest-warn-perl install
libtest-yaml-valid-perl install
+libtext-bidi-perl install
libtext-charwidth-perl install
libtext-csv-encoded-perl install
libtext-csv-perl install
diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl
index e23b068..f0a7290 100755
--- a/labels/label-create-pdf.pl
+++ b/labels/label-create-pdf.pl
@@ -26,6 +26,7 @@ use C4::Auth;
use C4::Debug;
use C4::Creators;
use C4::Labels;
+use Text::Bidi qw( log2vis );
my $cgi = new CGI;
@@ -90,7 +91,8 @@ sub _print_text {
foreach my $text_line (@$label_text) {
$pdf->Font($text_line->{'font'});
$pdf->FontSize( $text_line->{'font_size'} );
- $pdf->Text( $text_line->{'text_llx'}, $text_line->{'text_lly'}, $text_line->{'line'} );
+ my $visual = log2vis( $text_line->{'line'} );
+ $pdf->Text( $text_line->{'text_llx'}, $text_line->{'text_lly'}, $visual );
}
}
--
1.7.9.5