Working with Fonts and Railo

I was using ColdFusion MX (i.e., the cfdocument tag) to generate some reports and it was working OK. However, we’ve recently switched to Railo and its tag implementation had severe issues generating JCK fonts. While ColdFusion uses iText for generating a PDF, Railo uses PD4ML.

PD4ML has a severe issue (i.e., bug) regarding fonts. It doesn’t use the default Swing/AWT mechanism for generating texts, instead it looks for TTF defined fonts in the fonts.jar file (WEB-INF/lib/fonts.jar). The reasons behind this are explained in this page. What’s more, this mechanism only supports TTF (not TTC) fonts, so it was kind of hard locating a font with the following conditions:

  1. Sans
  2. TTF Distributed
  3. Similar to Arial
  4. Supporting JCK (at least)
  5. Free to use and distribute

This last point is important: since you have to embed the font within the PDF, the license is important. If you embed the font, then you’re not just using it, you are also distributing it. So even if I used the Unicode variant of Arial, as far as I could tell, there would be issues because we were distributing it to other systems. The closest fit I found was the “Droid Sans Fallback” theme, under the Apache License.

Since PD4ML is completely based on CSS for generating the document, I had to change all the font-family directives to “Droid Sans Fallback” and leave sans-serif as an hypothetical fallback (i.e., this should never happen). There doesn’t seem to be that much difference, but you may want to double check for your particular reports. Also if you’re not using Arial then good luck finding a Pan-Unicode font similar to the one you were using.

After that the steps for generating Japanese-Chinese-Korean reports in Railo are:

  1. Modify the fonts.jar file (add your TTF file and its mapping in the config file)
  2. Modify your PDF CSS (so the font-family directive asks for the new Font and uses the previous one as a Fallback)
  3. Restart your server
  4. Enjoy!

 

Focus Mode

Contact Request

Close

We will call you right away. All information is kept private