nicksagona / popphp-v1-legacy

Pop PHP Framework v1.7.0 : A Lightweight PHP Framework
http://www.popphp.org/
Other
42 stars 7 forks source link

pdf kerning #5

Closed marcdakar closed 10 years ago

marcdakar commented 10 years ago

hi, thanks for this awesome framwork

im just exploring the pdf function and found a problem with kerning of german unlaute please point me in the right direction to solve this, thank you ... marc

this is the pdf http://bludomain.de/test.pdf

code: require_once '../../bootstrap.php';

use Pop\Pdf\Pdf; try { $pdf = new Pdf('doc.pdf'); $pdf->addPage('Letter'); $pdf->setCompression(true);

$pdf->setVersion('1.4')
    ->setTitle('Test Title')
    ->setAuthor('Test Author')
    ->setSubject('Test Subject')
    ->setCreateDate(date('D, M j, Y h:i A'));

 $pdf->addFont('../assets/fonts/BicklySc.TTF', true);
 $pdf->addText(50, 620, 28, utf8_decode('Wünsche mir schließlich the Pop PHP Framework !'), $pdf->getLastFontName());

$pdf->output();

} catch (\Exception $e) { echo $e->getMessage(); }

nicksagona commented 10 years ago

Hey thanks for checking out the framework. I'll take a look and see what the issue is.

Nick

nicksagona commented 10 years ago

Hey, I'm finally getting a chance to look at this. It's looking like it's an issue with the width of multi-byte characters. I'm going to look into it and see if I can figure out a fix. Thanks - Nick

nicksagona commented 10 years ago

Ok, I was able to fix the encoding of the fonts, including the 13 standard Adobe fonts and the embedded fonts as well. However, in testing it, the results looked correct for most fonts I tested it with, but still a little off for a couple of other fonts. It may be an issue on the font level, and which font is chosen to be embedded in the PDF.

A couple of additional notes:

So go ahead and get the latest copy and test it out.

Here's my code to test it with a handful of TTF and OTF fonts:

$pdf = new Pdf('doc.pdf');

$pdf->addPage('Letter');

$pdf->setVersion('1.4')
    ->setTitle('Test Title')
    ->setAuthor('Test Author')
    ->setSubject('Test Subject')
    ->setCreateDate(date('D, M j, Y h:i A'));

$pdf->addFont('/home/nick/Desktop/fonts/ARRUSB.TTF');
//$pdf->addFont('/home/nick/Desktop/fonts/AVGARDM.TTF');
//$pdf->addFont('/home/nick/Desktop/fonts/bgothl.ttf');
//$pdf->addFont('/home/nick/Desktop/fonts/BlackoakStd.otf');
//$pdf->addFont('/home/nick/Desktop/fonts/BrushScriptStd.otf');
//$pdf->addFont('/home/nick/Desktop/fonts/ChaparralPro-Bold.otf');
//$pdf->addFont('/home/nick/Desktop/fonts/CooperBlackStd.otf');

$pdf->addText(50, 620, 18, 'Wünsche mir schließlich the Pop PHP Framework!');
$pdf->output();

And here are the PDF files that were produced by the code: http://www.moc10dev.com/pdf/font-arrusb.pdf http://www.moc10dev.com/pdf/font-avgardm.pdf http://www.moc10dev.com/pdf/font-bgothl.pdf http://www.moc10dev.com/pdf/font-blackoak.pdf http://www.moc10dev.com/pdf/font-brushscript.pdf http://www.moc10dev.com/pdf/font-chaparral.pdf http://www.moc10dev.com/pdf/font-cooper.pdf