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 index: glyf - phenx/php-font-lib/src/FontLib/TrueType/File.php, line 329 #65

Closed consolibyte closed 6 months ago

consolibyte commented 6 years ago

PHP 7.0.6

The line in question is this:

  /**
   * @param $name
   *
   * @return Table
   */
  public function getTableObject($name) {
    return $this->data[$name];
  }
consolibyte commented 6 years ago

This seems to be somehow related to these styles -- if I remove these styles from my DomPDF document, the error goes away:

@font-face {
                font-family: 'Basis Grotesque';
                font-style: normal;
                font-weight: 400;
                src: url('/chargeover/fonts/basis-grotesque-regular-pro.otf');
            }

            @font-face {
                font-family: 'Basis Grotesque';
                font-style: bold;
                font-weight: 700;
                src: url('/chargeover/fonts/basis_grotesque_bold.otf');
            }

            * {
                font-family: "Basis Grotesque", sans-serif;
            }

            div, td {
                font-family: "Basis Grotesque", sans-serif;
                color: black;
                vertical-align: top;
            }
bsweeney commented 6 years ago

Dompdf doesn't support OTF fonts at present. Do you have TTF versions?

keith-chargeover commented 6 years ago

That's interesting... since the OTF versions were working fine up until I upgraded to DomPDF 8.0.1.

I do have the TTF versions, but they result in the same error message. However, the TTF versions I have were converted from the OTF versions. I have attached both versions.

Archive.zip

bsweeney commented 6 years ago

I'd be curious to see a sample HTML document and the resulting render from before. But you might open an issue in the Dompdf project since that's a concern not directly related to this error. With Dompdf 0.8.0 we added more checks in the font management portion of Dompdf to prevent processing of non-TTF files. Still, in earlier version I wouldn't expect Dompdf to process the font correctly.

onassar commented 6 years ago

I'm also getting this with specific fonts.

bsweeney commented 6 months ago

Not that this error occurs when attempting to subset a font that does not include a glyf table. A number of OpenType fonts use the CFF table instead. For full support ensure any font you're attempting to parse includes a glyf table.

Watch #10 for updates.