LDX Design

LearnDash Design & Tutorials

LearnDash Design & Tutorials

LearnDash Certificate Font Issues: Question Marks, Accents & How to Fix Them

Having trouble with certain unicode characters on your LearnDash certificates? Do you have students whose names contain letters with special accent marks? Or are you just seeing question marks on your certificates and have no idea why?

LearnDash allows you to offer certificates to your students after successful completion of quizzes and/or courses, but in rare cases, the student’s name might not appear correctly. The most common reason for this is the default font used for PDF generation doesn’t support certain special characters.

Shoutout: Kudos to Ken & Patrick from the LearnDash LMS Tips & Tricks Facebook Group for raising the issue and finding the solution.

Quick Background on Certificate Generation

…or just jump right to the solution.

I just recently learned this myself, but it’s helpful to have a basic understanding on how LearnDash generates certificates. Here’s the super-simple, non-technical explanation.

LearnDash uses a third-party script called TCPDF to take the information you enter on a certificate in WordPress and convert it into a PDF that is generated on the fly. This script is included with the LearnDash plugin, and it comes with a handful of pre-determined defaults. One of those defaults is the font. Herein lies the issue.

LearnDash Default Certificate Font

By default, LearnDash sets the TCPDF default font to Helvetica. If you want to see it for yourself, open this file:

wp-content/plugins/sfwd-lms/includes/vendor/tcpdf/config/tcpdf_config.php
TCPDF default font code
Here’s the actual code that sets the default font for TCPDF in the config file

The version of Helvetica that comes with TCPDF in LearnDash doesn’t support every single character in the UTF-8 character set. I did some testing, and here’s an example of similar characters that it supports & doesn’t support.

  • Supports: è, é, ê, ë
  • Does not support: ē, ė, ę

I also tested it using the default serif font, adding <span style="font-family: serif;"> around the characters, but I got the same result as above.

How to Change the Default Certificate Font

I didn’t test every single unicode character (that’d be crazy 🤯), but I did test all the versions of the e above with the following fonts. I’m hopeful that if a font supports those characters, it should support the rest. Here’s what I know works:

Font Family Support
Open Sans Yes
Roboto Yes
Raleway Yes
Libre Baskerville Yes
Merriweather Yes
Montserrat Yes
Lato No

I only tested the “Regular” 400 weight version of each font. You can download a .zip file of all the TCPDF files for the above fonts. Choose one you like. Then skip to step #4 below.

LearnDash also has a TCPDF version of Arial here.

If you try this with other fonts, please let us know in the comments.

1. Download New Font from Google Fonts

  1. Navigate to fonts.google.com
  2. Search for the font you want to use (we’re using Open Sans in this example)
  3. Click the + icon to add it to your selection
  4. Click the download icon to download it to your computer

2. Convert Font from TTF to TCPDF Format

  1. Locate the .TTF file on your computer
  2. Navigate to fonts.snm-portal.com
  3. Drag’n’drop the .TTF file into the drop zone
  4. Check the box that says you have the rights to convert this font

3. Download TCPDF Font Files

  1. Make note of the Fontname value. You’ll need this in a second.
  2. Right-click and Save As for each of the three files:
    • opensans.z
    • opensans.ctg.z
    • opensans.php

4. Copy TCPDF Files to LearnDash

Using SFTP, or your method of choice, upload those three files into this directory:

wp-content/plugins/sfwd-lms/includes/vendor/tcpdf/fonts/

5. Update TCPDF Config File

Finally, you need to edit this file:

wp-content/plugins/sfwd-lms/includes/vendor/tcpdf/config/tcpdf_config.php

Search for this line:

define ('PDF_FONT_NAME_MAIN', 'helvetica');

Replace it with this line:

define ('PDF_FONT_NAME_MAIN', 'opensans');

You would change opensans to whatever your Fontname is.

IMPORTANT! Any time you update LearnDash to a new version, your code will be erased. You’ll likely need to upload the font files again, and edit the config file. Currently, there is no way around this, so save those 3 files.

Certificates in LearnDash 3.0

LearnDash 3.0 is scheduled for release sometime in Q1 2019. The CEO, Justin, has mentioned there will be improvements to LearnDash certificates. I’m hoping there might be some built in font choices, or at least better support for changing the default font without editing the plugin files.


Speaking of LearnDash certificates: Patrick has a LearnDash certificate tracker plugin you can download for free here. (Offered “as-is”. No support.)

Previous

How to Hide or Move LearnDash Progress Dots

Next

How to Display Course Title Over the Image in LearnDash Course Grid

4 Comments

  1. Kakybat

    very useful post!!!

  2. only24

    Hi! If you want to continue update your plugin you can define font in wp_config.php file in root of your site.

  3. Vitaly

    Very nice post!

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress & Theme by Anders Norén