GravityPDF / gravity-pdf

Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using Gravity Forms.
https://gravitypdf.com
88 stars 21 forks source link

If a custom font fails to install, upon retrying automatically disable OTL checker. #1429

Closed jakejackson1 closed 10 months ago

jakejackson1 commented 1 year ago

Description

The Noto Sans Bold TTF font file (downloaded direct from fonts.google.com) causes a PHP fatal error due to a max memory issue upon adding to the Font Manager.

The reasons for the fatal error is when mPDF is parsing the font file the OTL Ligature set data extracted from the file is creating some very large loops. This suggests there is an underlying issue with mPDF's font reader, but I don't know enough about working with binary font files in PHP, or their structure, to make any sort of determination.

The workaround I have come up with is to disable the OTL checker if the installation fails and the user selects retry. This will prevent the Ligature set from being extracted from the OTL font data, and stop the fatal error.

Step To Reproduce Steps to reproduce the behavior:

  1. Download the Noto Sans zip from Google Fonts
  2. Open the Font Manager
  3. In the Add Font panel, select the Noto Sans Bold TTF font file for the Regular box and save
  4. See error

Expected behavior The font successfully saves.

jakejackson1 commented 1 year ago

mPDF memory limit is being hit while processing the GSUB Ligatures.

Here is the spec: https://learn.microsoft.com/en-us/typography/opentype/spec/

Reviewing it and the mPDF code might yield answers for the faulty data.

jakejackson1 commented 10 months ago

Haven't been able to replicate with latest version of Gravity PDF