Some Context
This post is targeted toward any developers (or soon to be developers) that need to produce multi-language certificates of completion for Moodle. The Moodle certificate module delivers certificates by generating PDF files. I had assumed that PDFs benefited from the same gains that web applications have with the advent of unicode character sets. The reality is more nuanced when it comes to multi-language documents.Moodle's PDF font support is broken, but soon to be fixed
During the Moodle 2 development process, Moodle HQ made a sensible decision to remove some of the less commonly used PDF fonts to reduce the size of the Moodle source code installation. This especially made sense given that there was little or no core functionality that used the TCPDF library that contained the fonts and the fonts used a lot of disk space. More recently the TCPDF library version was updated for the Moodle 2.6 release. Changes in the underlying library broke Moodle's support for installing additional fonts. See https://tracker.moodle.org/browse/MDL-47333 for details (fix slated for release around November 14th M2.6.6 and M2.7.3 releases).
The idea is that you can install the full set of PDF fonts from the TCPDF project by
- Downloading fonts file from project http://sourceforge.net/projects/tcpdf/files/
- Unzip and place the fonts folder into your Moodle dataroot folder
- Reference additional fonts by creating a custom certificate type. See https://docs.moodle.org/19/en/Certificate_module#Customize_format for creating custom certificate type. Although Moodle 1.9 specific documentation, the Moodle 2.x version of the document doesn't have the details for making a custom type and the basic instructions are still the same.
No universal free unicode font for all languages
For our project, we were hoping to make one custom certificate type that would work with any of the 14 language versions of the course. This would allow us to use Moodle's built-in language pack and editing capabilities to provide the correct unicode text for each language. What we found in practice is there was no single free font that had all 40k+ characters needed for universal coverage.
We also found that some fonts would have the characters for a language in one style but not another. For example we used the freeserif and freesans fonts (included in Moodle) for the prototype. We found that with a bold font style we couldn't output Hindi characters.
With some research, we did find a commercial font ($165 license fee) that has all the characters needed to make universal certificate types, but the client was not sure if the licensing terms made it legal to use in a web application such as this and opted for creating multiple certificate types.
Related links
- http://www.tcpdf.org/fonts.php
- http://stackoverflow.com/questions/8737772/tcpdf-encode-chinese-character
- http://www.fonts.com/font/ascender/arial-unicode
Asian fonts are special
CID-0 fonts are "non-embeddable" fonts. The idea is that they are supposed to be provided by the PDF reader. They are a bit like core fonts in this regard, but unlike core fonts which are generally included with your PDF reader download, these fonts need to be downloaded separately. The TCPF configuration for each of these fonts seems to reference the same basic font with an additional code to specify the specific language and character set. In practice, this meant we had to generate 5 custom certificate types to get complete coverage for the 14 language course.
- Latin, cyrillic, arabic cert type (fonts freesans, freeserif without use of bold style)
- Traditional Chinese cert type (font cid0ct)
- Simplified Chinese cert type (font cid0cs)
- Korean cert type (font cid0kr)
- Japanese cert type (font cid0jp)
If you are an Adobe Acrobat user, you will automatically be prompted to download the CID-0 fonts if you open a PDF that uses them. This brings us to our final tip.