Custom fonts in PDFs!

Custom fonts support in PDFs now work and will be available in the next release. Basically, here's all what you have to do:
  • Create a fonts directory at the root of your Novelang project.
  • Copy all the True Type fonts (.ttf files) you need here, suffixing the font name with bold.ttf, italic.ttf, and bold-italic.ttf, according to corresponding style and weight.
  • Check if all fonts are healthy by requesting the font listing to Novelang from your Web browser.
  • Enjoy, and set the font-family attribute in your stylesheets.
The URL for listing fonts is:
The listing displays all reccognized fonts with their name, the file name, and most of characters supported by Novelang grammar. The font directory may be set explicitely, with the novelang.fonts.dir. FOP, the PDF generator, needs to create a file for each font with font metrics. By default it is created in a fop-metrics directory under the Novelang project root, but this can be set to another place by setting the novelang.fop.fontmetrics.dir system property. If there is something wrong with any font in the directory, there is no custom font at all by now and the error message only displays in the log file. If you download free fonts on the Internet you will learn quickly that many are full of bugs and missing letters (especially accents) so I recommand to add them one by one and restart Novelang each time. FOP has its own limitations when dealing with fonts. True Type fonts define bold, italic and bold + italic as four different fonts. Operating systems and desktop applications show the families as a whole (but you know, they lie all the time). In order to remain platform-independant, Novelang uses the most simple convention. First it seemed inconvenient to require a copy of every needed font, but now it appears as a good thing to me. People using publishing tools often complain about a missing font, or a buggy one. Making font files a part of your Novelang project, with the same sharing and backup strategy as for content and stylesheet, is a clear way to gain in robustness. Possible usability improvements:
  • List broken fonts in the font listing.
  • Support several font directories.
  • Support True Type Collections (FOP does that).
  • Support Type One fonts (FOP does that).
  • Detect font file change on the disk and therefore provide an updated listing. Restarting Novelang after adding a font wouldn't be required anymore.
  • Use a temporary directory for font metrics files.

No comments: