tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

Fix composite glyph output #581

Closed ren1244 closed 1 year ago

ren1244 commented 1 year ago

Fix Composite Glyph Output

overview

Problem Reproduction

  1. Test Font: kaiu.ttf
  2. Test Code
    
    <?php
    require('vendor/autoload.php');

// add test font $font = TCPDF_FONTS::addTTFfont('kaiu.ttf');

// create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false);

// set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);

// set default font subsetting mode $pdf->setFontSubsetting(true);

// set font $pdf->SetFont($font, '', 12);

// add a page $pdf->AddPage();

// get esternal file content $utf8text = "月落烏啼霜滿天\n江楓漁火對愁眠\n姑蘇城外寒山寺\n夜半鐘聲到客船";

// write the text $pdf->Write(5, $utf8text, '', 0, '', false, 0, false, false, 0);

//Close and output PDF document $pdf->Output('example_008.pdf', 'I');



## Related Reference

[https://learn.microsoft.com/en-us/typography/opentype/spec/otff](https://learn.microsoft.com/en-us/typography/opentype/spec/otff)

> All tables must begin on four-byte boundaries, and any remaining space between tables must be padded with zeros. The length of each table should be recorded in the table record with the actual length of data, not the padded length.
CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

ren1244 commented 1 year ago

This PR also fix a bug about subset. Please review tcpdf_fonts.php line 1386. CheckSumAdjustment write to wrong position. It cause unpredictable behavior.

ren1244 commented 1 year ago

bff5f0f Update code to fit _getTTFtableChecksum requirements