Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RT 126274] unifont -indent fails if text is not in multiple block #96

Closed
PhilterPaper opened this issue Aug 15, 2018 · 3 comments
Closed
Labels
bug something not working to spec, or causes crash

Comments

@PhilterPaper
Copy link
Owner

Tue Aug 14 17:29:32 2018 fcc_del [...] bc.hu - Ticket created
Subject: unifont -indent fails if text is not in multiple block
Date: Tue, 14 Aug 2018 22:51:46 +0200 (CEST)
From: fcc_del [...] bc.hu

methods: text_center, text_right
And at lower level, the value of -indent key and variable $ident does not work properly, if the text can be printed using only one font inside unifont.

The attached unierror.pl can demonstrate it. The result is unierror.pdf

I'm using debian, perl 5.10.1 (not relevant for the bug)

package PDF::API2::Resource::UniFont;
our $VERSION = '2.023'; # VERSION

The following patch can solve this problem.

Patch:

--- unifont-old.pm 2014-09-12 00:00:00.000000000 +0200
+++ UniFont.pm 2018-08-14 22:32:16.938551934 +0200
@@ -276,7 +276,15 @@
    if(scalar @codes > 0)
   {
     my $f=$self->fontlist->[$lastfont];
-    $newtext.='/'.$f->name.' '.$size.' Tf '.$f->text(pack('U*',@codes),$size).' ';
+    if(defined($ident) && $ident!=0)
+    {
+       $newtext.='/'.$f->name.' '.$size.' Tf ['.$ident.' '.$f->text(pack('U*',@codes)).'] TJ ';
+       $ident=undef;
+    } 
+    else
+    {
+       $newtext.='/'.$f->name.' '.$size.' Tf '.$f->text(pack('U*',@codes)).' Tj ';
+    }
   }
 
   return($newtext);
}

Thank you for your help

unierror.pl.txt
unierror.pdf

@PhilterPaper
Copy link
Owner Author

PhilterPaper commented Aug 15, 2018

A few lines before this patch is another section of code that has almost the same patch applied. Perhaps it should have been done in both places?

Also note that although the option is -indent, the variable is $ident. Need to check if this is a typo.

@PhilterPaper PhilterPaper added the bug something not working to spec, or causes crash label Aug 15, 2018
@PhilterPaper
Copy link
Owner Author

PhilterPaper commented Aug 25, 2018

Typo for variable name fixed in BaseFont.pm, CIDFont.pm, UniFont.pm: $ident should be $indent.

Investigated reported bug and found that it was a missing parameter on a recursive call to text(). The last parameter, $indent, was missing. This fix appears to work OK, and is much cleaner than the suggested fix.

This change will appear in PDF::Builder 3.011 (possibly around end of 2018).

A note if you are looking at the supplied test case (unierror.pl). Be aware that in Helvetica (a corefont), the o+Hungarian-umlaut character doesn't have a listed glyph width, so it gets the "missing glyph" default width, which is quite narrow, resulting in incorrect alignment on text_right and text_center. See RT 57248/ #7 for more on this.

@PhilterPaper
Copy link
Owner Author

Thu May 16 21:47:24 2019 steve [...] deefs.net - Correspondence added

Thanks for the bug report!

I've incorporated your fix with minor changes, cleaned up the surrounding code, and added a couple of tests. It'll be included in the next release.

On Tue Aug 14 17:29:32 2018, fcc_del@bc.hu wrote:

Thu May 16 21:47:25 2019 steve [...] deefs.net - Status changed from 'open' to 'patched'

On Thu May 16 21:47:24 2019, SSIMMS wrote:

Steve, you may want to read #96. The fix (missing parameter to text() call) is much simpler than the suggested one. I will look at your changes to see if there's anything I overlooked. I see you have made other changes in this group that may be of interest for Builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something not working to spec, or causes crash
Projects
None yet
Development

No branches or pull requests

1 participant