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

Fix composite glyph output #581

Merged
merged 3 commits into from
Sep 6, 2023
Merged

Fix composite glyph output #581

merged 3 commits into from
Sep 6, 2023

Conversation

ren1244
Copy link
Contributor

@ren1244 ren1244 commented Jan 15, 2023

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

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
Copy link

CLAassistant commented Jan 15, 2023

CLA assistant check
All committers have signed the CLA.

@ren1244
Copy link
Contributor Author

ren1244 commented Jan 16, 2023

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
Copy link
Contributor Author

ren1244 commented Jan 21, 2023

bff5f0f Update code to fit _getTTFtableChecksum requirements

@williamdes williamdes mentioned this pull request Aug 2, 2023
@nicolaasuni nicolaasuni merged commit 7e3fb6f into tecnickcom:main Sep 6, 2023
0 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants