ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 21 forks source link

Symbol (core)fonts and utf8 clash #55

Open sciurius opened 2 years ago

sciurius commented 2 years ago

Short description: When an perl string containing utf8 characters is printed with Symbol or ZapfDingbats corefont, nothing (a sequence of null characters) is printed.

use strict;
use utf8;
use PDF::API2 2.043;   # Or PDF::Builder

my $pdf = PDF::API2->new;
my $page = $pdf->page;
my $text = $page->text;

# First, use corefont Times-Roman.
# "ABC" is shown twice (the smiley cannot be printed
# since it is not in the corefont).
my $font = $pdf->font("Times-Roman");
$text->font($font,30);
$text->translate(100,700);
$text->text("ABC");     # (ABC) Tj
$text->translate(200,700);
$text->text("ABC☺");        # (ABC\0) Tj

# Now, use a symol corefont.
# "ABC" is shown once, the second occurrence completely disappears.
$font = $pdf->font("ZapfDingbats");
$text->font($font,30);
$text->translate(100,600);
$text->text("ABC");     # (ABC) Tj
$text->translate(200,600);
$text->text("ABC☺");        # (\0\0\0\0) Tj

$pdf->save("plain.pdf");
sciurius commented 2 years ago

issue055_pl.txt