1

When running the tcpdf_addfont.php tool for generating font files used by tcpdf

  php .\tcpdf_addfont.php -i HansomFY-Light_S.otf

I am getting the following error message:

  *** Output dir set to C:\xampp2\htdocs\vboxCode\flow-api\TCPDF-master/fonts/
  --- ERROR: can't add HansomFY-Light_S.otf
  --- Process completed with ERRORS!

Is it not possible to use otf for this tool?

bananaCute
  • 433
  • 5
  • 17
  • Where does come from HansomFY-Light_S.otf ? is there any other error message ? – Frankich May 23 '19 at 09:04
  • Hi @Frankich its the same folder with the tcpdf_addfont.php – bananaCute May 23 '19 at 09:08
  • Can you host your file somewhere, so that I can have a test on your font? – Raptor May 23 '19 at 10:10
  • @Frankich I used the current version from Github, without modifying any codes. See the result yourself: https://imgur.com/a/6VTJm3J . *My advice? Never say never.* – Raptor May 24 '19 at 02:05
  • 1
    @bananaCute your problem is not related to converting the font to TTF. 1. it might be path problem (as you can see your path mix with slash and backslash); 2. The font integrity has problems (as I advised in comments earlier, you can check with font tools). *In short, TCPDF supports OTF format; converting to TTF is unnecessary.* – Raptor May 24 '19 at 02:08
  • @Raptor how to check the font intigrety? – bananaCute May 24 '19 at 02:21
  • 1
    If you are using macOS, you can use the built-in FontBook app. for Windows, Microsoft has provided a tool to do similar work: https://github.com/microsoft/Font-Validator – Raptor May 24 '19 at 04:52

1 Answers1

0

I had a similar problem with a font to support Chinese, apparently TCPDF doesn't support OpenType formats that use CFF data, I tried to convert the font to .ttf with fontforge but then tcpdf_addfont had problems converting with something missing in the font, I could use the font imported but the quality result was poor (like condensed), I had better results using this python snippet from fonttools

Alex
  • 3,264
  • 1
  • 25
  • 40