Skip to content

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