Menu

OTF-Fonts in TCPDF

Help
anmu
2015-08-19
2015-08-19
  • anmu

    anmu - 2015-08-19

    According to the main features of TCPDF this should support OpenType and OpenType Unicode fonts. However, this does not work with me. I use the latest version (6.2.11)

    If I do this (from here: http://www.tcpdf.org/fonts.php):
    -->
    $fontname = TCPDF_FONTS::addTTFfont('newfont.otf', 'OpenTypeUnicode', '', 32);
    $pdf->SetFont($fontname, '', 14, '', true);
    <--

    I get this error:

    "TCPDF ERROR: Could not include font definition file: "

    That's because the value of $fontname is "FALSE" and then SetFont not working.
    I then tried it with the command line:

    ./tcpdf_addfont.php -i newfont.otf

    This does not work either:
    -->

    Converting fonts for TCPDF:
    *** Output dir set to /var/www/public_html/inc/tcpdf/fonts/
    --- ERROR: can't add newfont.otf
    --- Process completed with ERRORS!
    <--

    I have tried this with different fonts, which also use my Windows system (eg BirchStd.otf, AdobeArabic-Bold.otf), always with the same result.

    Supports TCPDF OTF fonts not correct? (https://sourceforge.net/p/tcpdf/discussion/435311/thread/52b69364/#2e63)

    Is there any way to use .otf fonts with TCPDF?

    Best regards
    AM

     
    • epistaxis

      epistaxis - 2015-08-19

      On Wed, 19 Aug 2015 15:30:32 +0000
      "anmu" anmu@users.sf.net wrote:

      Is there any way to use .otf fonts with TCPDF?

      Yup, I use OTF Switzera ADF Light Cd font formerly prepared this way:

      • Copy <zefontthatiwantsobadlyformywonderfulpdf>.otf in, let say
        tcpdf/fonts/MYOWNFONTS
      • Install fontforge and launch it
      • Open an OTF font file
      • Element > Font Info > Layers Tab: Check 'All layers quadratic'
      • Edit > Select > Select All (do not use CTRL-A: it doesn't work)
      • Hints > AutoInstr
      • File > Generate Fonts (make sure TrueType is selected)
      • Hit the OK button

      That should do the trick: creating .ttf file
      that you will move one level below (in tcpdf/fonts).

      After that, import your font as you'd do with any other TTF.

      Jean-Yves

       

Log in to post a comment.