From: Bernardo Gonzalez Kriegel Date: Wed, 23 Apr 2014 21:18:25 +0000 (-0300) Subject: Bug 12068 - label-create-pdf.pl Add support for RTL language X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=0ac72275aac8a2d0511b021cee0643aa38a7ba09;p=koha.git 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 NOTE: I suggest changing the mapping for 'HO' font on koha-conf.xml, from DejaVuSans-Oblique.ttf to DejaVuSans.ttf to view 'title' chars 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 (unless you change mapping as suggested on 2. ) Hebrew looks good. Rebased and move use of new dependency to Labels.pm Rebased on master Signed-off-by: Karam Qubsi Signed-off-by: Katrin Fischer Tested with the help of Bernardo. With the patch the characters of RTL strings appear in the correct order in the generated PDF files. Signed-off-by: Tomas Cohen Arazi --- diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index 376985e4c3..d6d7288fb9 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -702,11 +702,17 @@ our $PERL_DEPS = { 'required' => '0', 'min_ver' => '5.836', }, + 'Test::DBIx::Class' => { 'usage' => 'Testing modules utilising DBIx::Class', 'required' => '0', 'min_ver' => '0.42', }, + 'Text::Bidi' => { + 'usage' => 'Label batch PDF', + 'required' => '0', + 'min_ver' => '0.03', + }, }; 1; diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index eb2800680c..ff6c8654e5 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -8,6 +8,7 @@ use Algorithm::CheckDigits; use Text::CSV_XS; use Data::Dumper; use Library::CallNumber::LC; +use Text::Bidi qw( log2vis ); use C4::Context; use C4::Debug; @@ -444,6 +445,7 @@ sub draw_label_text { foreach my $line (@label_lines) { next LABEL_LINES if $line eq ''; my $fontName = C4::Creators::PDF->Font($font); + $line = log2vis( $line ); my $string_width = C4::Creators::PDF->StrWidth($line, $fontName, $self->{'font_size'}); if ($self->{'justify'} eq 'R') { $text_llx = $params{'llx'} + $self->{'width'} - ($self->{'left_text_margin'} + $string_width); diff --git a/install_misc/debian.packages b/install_misc/debian.packages index 9c31206fb2..9b8ad6dc5d 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 17cfdc8951..d849d6ada2 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 c63aaf3ac6..5cf60173f3 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 aea298eb98..ff132c90f2 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