dompdf / php-font-lib

A library to read, parse, export and make subsets of different types of font files.
GNU Lesser General Public License v2.1
1.73k stars 256 forks source link

Undefined Offset in kern.php when using custom font #59

Closed brendt closed 6 years ago

brendt commented 7 years ago

We're getting this error:

ErrorException: Undefined offset: 12767

The code:

vendor/phenx/php-font-lib/src/FontLib/Table/Type/kern.php:51

45:         $tree  = array();
46: 
47:         $values = $font->readUInt16Many($subtable["nPairs"] * 3);
48:         for ($i = 0, $idx = 0; $i < $subtable["nPairs"]; $i++) {
49:           $left  = $values[$idx++];
50:           $right = $values[$idx++];
51:           $value = $values[$idx++];
52: 
53:           if ($value >= 0x8000) {
54:             $value -= 0x10000;

When using this setup

<style>
        @font-face {
            font-family: 'Flanders Art Sans Light';
            font-style: normal;
            font-weight: normal;
            src: url(http://kulibo.local.statik.be/fonts/FlSaLite.ttf) format('truetype');
        }

        @font-face {
            font-family: 'Flanders Art Sans';
            font-style: normal;
            font-weight: normal;
            src: url(http://kulibo.local.statik.be/fonts/FlSaReg.ttf) format('truetype');
        }

        @font-face {
            font-family: 'Flanders Art Sans Regular';
            font-style: normal;
            font-weight: normal;
            src: url(http://kulibo.local.statik.be/fonts/FlSaReg.ttf) format('truetype');
        }

        @font-face {
            font-family: 'Flanders Art Sans Medium';
            font-style: normal;
            font-weight: normal;
            src: url(http://kulibo.local.statik.be/fonts/FlSaMed.ttf) format('truetype');
        }

        @font-face {
            font-family: 'Flanders Art Sans Bold';
            font-style: normal;
            font-weight: normal;
            src: url(http://kulibo.local.statik.be/fonts/FlSaBold.ttf) format('truetype');
        }

        * {
            font-family: "Flanders Art Sans", serif;
        }

        h1 {
            font-family: "Flanders Art Sans Bold", serif;
        }
</style>
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/44629340-undefined-offset-in-kern-php-when-using-custom-font?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github).