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.
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:
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:
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
- Navigate to fonts.google.com
- Search for the font you want to use (we’re using Open Sans in this example)
- Click the + icon to add it to your selection
- Click the download icon to download it to your computer
2. Convert Font from TTF to TCPDF Format
- Locate the .TTF file on your computer
- Navigate to fonts.snm-portal.com
- Drag’n’drop the .TTF file into the drop zone
- Check the box that says you have the rights to convert this font
3. Download TCPDF Font Files
- Make note of the Fontname value. You’ll need this in a second.
- Right-click and Save As for each of the three files:
4. Copy TCPDF Files to LearnDash
Using SFTP, or your method of choice, upload those three files into this directory:
5. Update TCPDF Config File
Finally, you need to edit this file:
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.)