On top of Bug 8375 Right-to-left languages are not properly displayed on PDF, chars are presented in logical order from left to right
Created attachment 26984 [details] [review] 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.
Created attachment 27336 [details] [review] 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.
Created attachment 27503 [details] [review] 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
When I run koha-qa, got something strange FAIL C4/Labels/Label.pm OK pod OK forbidden patterns FAIL valid Name "swig_runtime_data::type_pointer3" used only once: possible FAIL labels/label-create-pdf.pl OK pod OK forbidden patterns FAIL valid Name "swig_runtime_data::type_pointer3" used only once: possible typo Perhaps only my machine, can't understand :(
Seems to be something related with Text::Bidi library, see http://www.cpantesters.org/cpan/report/cd6c2fe8-da0a-11e0-bbec-9aeec8b7ec30
If you run perl -cwe "use Text::Bidi;" then the output is Name "swig_runtime_data::type_pointer3" used only once: possible typo at /usr/lib/perl/5.14/DynaLoader.pm line 207. -e syntax OK That's the reason koha-qa complains. Can't find another lib to replace Text::Bidi, and without it we can't print RTL labels correctly Patch still valid, save for small conflict on PerlDependencies.pm
Created attachment 30775 [details] [review] 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
Another comment about the 'version' of Text::Bidi On Ubuntu 12.04 it's version is 0.03-5build2, on Debian sqeeze and weezy is also 0.03-5, but on Ubuntu 14.04 it's now 2.08, and for Debian Jessie it's 2.09 With 2.08 test does not fail!!
Created attachment 30792 [details] [review] [SIGNED-OFF]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 <karamqubsi@gmail.com> this patch works as described : the fonts in koha-conf.xml are modified as the following <font type="H" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf</font> <font type="HO" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf</font> Hlvetica oblique is mapped to the same file as helvetica I used a layout with "Helvetica" font and with right justification, 7 font size I tested it with an Arabic items the results exported is very good for me as an Arabic reader Thank you Bernardo .
Created attachment 30793 [details] pdf exported file with Arabic items as you can see everything is perfect here :)
> the fonts in koha-conf.xml are modified as the following > <font type="H" > >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf</font> > <font type="HO" > >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf</font> Why isn't it: <font type="HO" /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf</font> instead?
(In reply to M. Tompsett from comment #11) > > Why isn't it: > <font type="HO" > /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf</font> > > instead? Problem is DejaVuSans-Oblique lack of Arabic glyphs :( Only DejaVuSans have a decent support for them. This is only a workaround to print Arabic labels. Correct solution is add an option to label layout to use o not Oblique/Italic variant for title.
Created attachment 32255 [details] [review] 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 <karamqubsi@gmail.com> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Tested with the help of Bernardo. With the patch the characters of RTL strings appear in the correct order in the generated PDF files.
Patch pushed to master. Thanks Bernardo!
t/00-load.t ......................... 2/? # Failed test 'use C4::Labels;' # at t/00-load.t line 33. # Tried to use 'C4::Labels'. # Error: Can't locate Text/Bidi.pm in @INC (you may need to install the Text::Bidi module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at C4/Labels/Label.pm line 11. # BEGIN failed--compilation aborted at C4/Labels/Label.pm line 11. Tests now fail, 2 options, either we make Text::Bidi mandatory (it's optional at the moment) or we switch C4/Labels to do a conditional load instead of a use. What would you prefer? I can do a patch for either.
Ah, I had done a patch to make it mandatory but forgot to attach it here :( Not sure which solution is better.
I feel like mandatory is probably the right thing, its a packaged module. If you add the patch ill sign it off
Created attachment 32614 [details] [review] Bug 12068: Follow up - make Text::Bidi mandatory Without the module some of the tests will fail. As this is fixing a serious bug for RTL language users, we agreed to make it mandatory.
Created attachment 32615 [details] [review] Bug 12068: Follow up - make Text::Bidi mandatory Without the module some of the tests will fail. As this is fixing a serious bug for RTL language users, we agreed to make it mandatory. Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Switching to "PQA" as the patch was intended to be QA follow-up and only changes one character.
Followup pushed to master. Thanks Katrina!
Thx Bernardo! :)
Can't locate ExtUtils/PkgConfig.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 9. It seems that fribidi is missing. fribidi should be installed prior to the installation of this module.
Hi Marcel, did you install Text::Bidi? It's a new dependency here.
(In reply to Katrin Fischer from comment #24) > Hi Marcel, did you install Text::Bidi? It's a new dependency here. Yes, that is actually my problem. I am not sure if this should have been marked as required btw..
Hi Marcel, can you explain?
(In reply to Katrin Fischer from comment #26) > Hi Marcel, can you explain? Installing Text::Bidi gives headaches: 0) I installed a fribidi with yum already (not on debian!) 1) After last error, installed ExtUtils::PkgConfig 2) Package fribidi was not found in the pkg-config search path. Made a fribidi.pc file 3) After several warnings and editing several lines in this fribidi.pc, I came one step further: 'YAML' not installed, will not store persistent state. 4) After installing YAML, got this fatal error: fribidi.h: No such file or directory. The installed fribidi appears to be a problem. So I am still stuck with this. Since I am not using this feature at all, I would not like to waste much more time on it.. Not sure if other people on other distros will have similar problems.
Hi Marcel, hope I didn't miss it, but which distro are you using? I think all I did was something like 'sudo apt-get install libtext-bidi-perl' - as it seemed to be ok on Ubuntu and Debian, I didn't see a problem here when we discussed the patch.
(12:15:07) marcelr: cait: fedora
(In reply to M. de Rooy from comment #27) > > Not sure if other people on other distros will have similar problems. I've just run into this problem today while using OpenSuse 13.2, and I'm pretty sure I ran into this problem in the past as well. The problem is that you're missing the headers for the fribidi library. If you do a "ls /usr/include/fribidi/fribidi.h", I suspect that you'll get nothing. Look for a package like "fribidi-devel" and install that, as that will include the headers that Text::Bidi needs when it's compiling code. You can see some of that in the guts of the Text::Bidi Makefile: http://cpansearch.perl.org/src/KAMENSKY/Text-Bidi-2.09/Makefile.PL I just installed "fribidi" and "fribidi-devel", and now I've managed to install Text::Bidi on OpenSuse 13.2. The building and testing took a long time, so be patient with it, but it should install once you have those fribidi C headers installed :).