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 #115

Merged
merged 3 commits into from
Nov 4, 2023
Merged

Fix composite glyph #115

merged 3 commits into from
Nov 4, 2023

Conversation

ren1244
Copy link
Contributor

@ren1244 ren1244 commented Jan 14, 2023

Fix Composite Glyph Output

overview

Problem Reproduction

  1. download kaiu.ttf and use dompdf/utils to load font
  2. test code
<?php
require('vendor/autoload.php');

use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml('
    <style>
    .font-zh {
        font-family: "kaiu";
        font-size: 14;
    }
    </style>
 
    <p class="font-zh">月落烏啼霜滿天<br>江楓漁火對愁眠<br>姑蘇城外寒山寺<br>夜半鐘聲到客船</p>
');

$dompdf->setPaper('A4', 'protrait');

$dompdf->render();

$dompdf->stream('test.pdf', [
    'Attachment' => 0
]);

Related Reference

  1. PDF 1.7 Reference page 468

The following TrueType tables are always required: “head,” “hhea,” “loca,” “maxp,” “cvt ,” “prep,” “glyf,” “hmtx,” and “fpgm.” If used with a simple font dictionary, the font program must additionally contain a “cmap” table.

  1. The C pseudo-code in OpenType spec - glyf
do {
    uint16 flags;
    uint16 glyphIndex;
    if ( flags & ARG_1_AND_2_ARE_WORDS) {
    (int16 or FWORD) argument1;
    (int16 or FWORD) argument2;
    } else {
        uint16 arg1and2; /* (arg1 << 8) | arg2 */
    }
    if ( flags & WE_HAVE_A_SCALE ) {
        F2DOT14  scale;    /* Format 2.14 */
    } else if ( flags & WE_HAVE_AN_X_AND_Y_SCALE ) {
        F2DOT14  xscale;    /* Format 2.14 */
        F2DOT14  yscale;    /* Format 2.14 */
    } else if ( flags & WE_HAVE_A_TWO_BY_TWO ) {
        F2DOT14  xscale;    /* Format 2.14 */
        F2DOT14  scale01;   /* Format 2.14 */
        F2DOT14  scale10;   /* Format 2.14 */
        F2DOT14  yscale;    /* Format 2.14 */
    }
} while ( flags & MORE_COMPONENTS )
if (flags & WE_HAVE_INSTR){
    uint16 numInstr
    uint8 instr[numInstr]

@bsweeney bsweeney added this to the 0.5.5 milestone Jan 14, 2023
src/FontLib/TrueType/File.php Outdated Show resolved Hide resolved
src/FontLib/Glyph/OutlineComposite.php Show resolved Hide resolved
src/FontLib/Table/Type/cvt.php Show resolved Hide resolved
@bsweeney bsweeney merged commit 05446c4 into dompdf:master Nov 4, 2023
11 of 12 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.

2 participants