# Custom Fonts in CFDocument

**URL:** <https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715>\
**Category:** support\
**Created:** [August 31, 2017, 8:28pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715 "2017-08-31T20:28:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [August 31, 2017, 8:28pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/1 "2017-08-31T20:28:33Z")

</div>

Hello,

I’m creating a PDF using cfdocument, and I’m struggling to include custom fonts in it. I’ve seen a couple threads about this topic and references to the well-done article at:

> **[Generating Accurate PDFs Using Cfdocument - Nando @ Aria Media](http://dnando.github.io/blog/2015/07/01/generating-accurate-pdfs-using-cfdocument/)**
>
> I’ve been developing a PDF, generated within a CFML application, that needs very accurate placement of chunks of text so that it can be printed …

But, for the life of me, I cannot get this working. My biggest stumbling block, at the moment, is that I don’t see the fonts.jar file that’s mentioned in the above article anywhere in my Lucee install. I’ve also tried downloading full Lucee installs from [Download Lucee](http://download.lucee.org/?type=releases) and searching through the directory structure, but I can’t find fonts.jar there, either.

Does anyone have any suggestions for either tracking down a copy of fonts.jar so that I can add my custom fonts to it, or an alternate method of including my custom fonts in a PDF generated with cfdocument?

I’m on Lucee 5.0.1.85, and it’s running as a Docker container.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![modius](https://dev.lucee.org/user_avatar/dev.lucee.org/modius/32/1722_2.png) [@modius](https://dev.lucee.org/u/modius)\
**Post date:** [September 1, 2017, 5:35am UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/2 "2017-09-01T05:35:38Z")

</div>

This might help:

[https://lucee.daemonite.io/t/problem-with-chinese-characters-in-pdf/467/4](https://lucee.daemonite.io/t/problem-with-chinese-characters-in-pdf/467/4)

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 1, 2017, 1:52pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/3 "2017-09-01T13:52:41Z")

</div>

Thanks! I found that article in my searches, but somehow missed the reply that you linked to. I downloaded the fonts.jar that was linked and I’m modifying it with my custom font, now.

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [September 1, 2017, 3:06pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/4 "2017-09-01T15:06:50Z")

</div>

FYI: we are planning to add a `fonts` directory where you can put custom fonts and it will use them from there automagically.

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 1, 2017, 3:27pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/5 "2017-09-01T15:27:44Z")

</div>

Automagic fonts would be fantastic. Any idea when that will be implemented?

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [September 1, 2017, 4:05pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/6 "2017-09-01T16:05:08Z")

</div>

No ETA ATM, but you can watch the ticket at  
[https://luceeserver.atlassian.net/browse/LDEV-1470](https://luceeserver.atlassian.net/browse/LDEV-1470)

Actually, you should **vote for it** there – the more votes, the higher the priority that the ticket will get.

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 1, 2017, 8:27pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/7 "2017-09-01T20:27:59Z")

</div>

Done! It now has 2 votes. 🙂

So, I’ve created my fonts.jar with my custom font and updated pdf4fonts.properties file, but I don’t have an /opt/lucee/lib folder. I do have /opt/lucee/web/lib, but I’ve put my fonts.jar in there and restarted lucee, but my custom fonts still don’t work. I also tried creating /opt/lucee/lib and putting fonts.jar, there. Any suggestions, here? I’ve also triple-checked the contents of my fonts.jar file, and I’m 99% certain they’re correct.

Thanks!

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 1, 2017, 9:32pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/8 "2017-09-01T21:32:49Z")

</div>

Actually, I think I’ve answered my own question. According to the logs, the copy of fonts.jar I have in /opt/lucee/web/lib is being loaded:  
“INFO”,“http-apr-8888-exec-2”,“09/01/2017”,“17:28:23”,“OSGi”,“add bundle:/opt/lucee/web/lib/fonts.jar”  
“INFO”,“http-apr-8888-exec-2”,“09/01/2017”,“17:28:23”,“OSGi”,“start bundle:fonts:0.0.0.0”

So, I guess now my issue is in my code? I’ll circle back to this on Tuesday. Thanks again, @21Solutions and @modius, for your help.

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [September 2, 2017, 1:16am UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/9 "2017-09-02T01:16:39Z")

</div>

Sorry but I didn’t get a chance to read the whole thread here, but see also my comments at:  
[https://luceeserver.atlassian.net/browse/LDEV-1273](https://luceeserver.atlassian.net/browse/LDEV-1273)

And ask again the specific question please if you still have one.

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 6, 2017, 9:06pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/10 "2017-09-06T21:06:35Z")

</div>

I’m not sure I have a specific question, at this point. I have, as far as I can tell, followed the instructions meticulously, but I can’t get my fonts to print to a pdf generated by cfdocument.

Here’s what I’ve tried. If anyone can tell me what I’m missing, I would certainly appreciate it.

I downloaded the fonts.jar from [Log in with Atlassian account](https://luceeserver.atlassian.net/browse/LDEV-12732), changed it to a zip, added my .ttf files, updated the pd4fonts.properties files, saved and renamed to fonts.jar.

I verified that the .ttf and .properties file in fonts.jar are in a subfolder named “fonts.”

Here’s a snippet from my pdf4fonts.properties file:

```auto
Monotype\ Corsiva=MTCORSVA.TTF
Century\ Gothic=GOTHICBI.TTF

```

I copied my fonts.jar to /opt/lucee/web/lib (This is a different path than what I’ve seen mentioned in other articles, but it appears to get loaded, according to application.log. I have, at various times, also tried putting my fonts.jar in /opt/lucee/lib, as mentioned in the links, above. But, that path didn’t exist in my lucee install, and I don’t see that fonts.jar get loaded, according to application.log)

After copying the fonts.jar file, I restarted Lucee. In fact, I restarted the whole Docker container.

I’m using the snippet, below, to test my custom font. Note that the Liberation Serif font, which is also included in fonts.jar, works as expected.

I’m really at a loss, here, so any and all suggestions are most welcome.

```auto
<cfcontent type="application/pdf">
<cfheader name="Content-Disposition" value="inline; filename=./seatingReport.pdf">
<cfdocument format="PDF" marginbottom="0" marginleft="0" marginright="0" margintop="0"
            orientation="landscape" overwrite="true" unit="in" localurl="true"
            fontembed="true">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
  <meta charset="UTF-8">
  <style type="text/css">
    @font-face {
      font-family: "Monotype Corsiva";
    }
    @font-face {
      font-family: "Century Gothic";
    }
    @font-face {
      font-family: "Liberation Serif";
    }
  </style>
</head>
<body>
<div>
      <span style="font-family:Monotype Corsiva;">Test</span><br />
      <span style="font-family:Century Gothic;">Test</span><br />
      <span style="font-family:Liberation Serif;">Liberation San</span>
    </div>
</body>
</html>
</cfdocument>

```

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 7, 2017, 5:59pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/11 "2017-09-07T17:59:50Z")

</div>

One more detail that I just noticed, today. When I use CFDocument, my custom fonts, Monotype Corsiva and Gothic Century, don’t load. But, the other custom fonts in fonts.jar, Liberation Sans and Liberation Serif, DO load. See screenshot:  
 ![](https://dev.lucee.org/uploads/default/original/1X/1a672c0db071ce66a7076ca2ef2338e797aae03b.png)

But, if I comment out CFDocument and just view my test page as html, my custom fonts DO load but the Liberation fonts DON’T load. What is going on here?  
 ![](https://dev.lucee.org/uploads/default/original/1X/32342d3cea438c3676f29182e84c23efcff4161b.png)

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [September 14, 2017, 5:24pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/12 "2017-09-14T17:24:33Z")

</div>

I suspect that there is another copy of a jar with a directory named `fonts` on your classpath, and that one is used rather than the one that you supplied.

> [@LuceeNewbie](#):
>
> I copied my fonts.jar to /opt/lucee/web/lib (This is a different path than what I’ve seen mentioned in other articles, but it appears to get loaded, according to application.log. I have, at various times, also tried putting my fonts.jar in /opt/lucee/lib, as mentioned in the links, above. But, that path didn’t exist in my lucee install, and I don’t see that fonts.jar get loaded, according to application.log)

This is probably where you go wrong. The fonts are not loaded by Lucee itself, but by a 3rd party library which loads them from the classpath. Try to put it in the same directory with the other jars of Tomcat, and restart Tomcat.

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 15, 2017, 9:04pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/13 "2017-09-15T21:04:40Z")

</div>

Thanks for the reply. I’ve never dealt with the classpath and the first article I found on it is a little daunting. I’ll muck around and see what I can find.

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [September 15, 2017, 9:15pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/14 "2017-09-15T21:15:07Z")

</div>

It’s very simple:

The classpath is a list of paths (directories/jars) where Java looks for when it tries to load a class or some other resource in the classic Java way (as opposed to OSGi).

You can put your fonts jar file next to the Lucee jar or next to the Tomcat (assuming you’re using Tomcat) jars which resides by default at {Tomcat}/lib. Then restart Tomcat/Lucee.

---

<div class="post-metadata">

**Author:** ![LuceeNewbie](https://dev.lucee.org/letter_avatar_proxy/v4/letter/l/34f0e0/32.png) [@LuceeNewbie](https://dev.lucee.org/u/LuceeNewbie)\
**Post date:** [September 18, 2017, 2:38pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/15 "2017-09-18T14:38:38Z")

</div>

Thanks. That’s much more straightforward than the article I was looking at: [https://www.mulesoft.com/tcat/tomcat-classpath](https://www.mulesoft.com/tcat/tomcat-classpath)

I’ll give it a try when things slow down, here.

---

<div class="post-metadata">

**Author:** ![David\_R](https://dev.lucee.org/user_avatar/dev.lucee.org/david_r/32/3098_2.png) [@David\_R](https://dev.lucee.org/u/David_R)\
**Post date:** [July 22, 2021, 4:17pm UTC](https://dev.lucee.org/t/custom-fonts-in-cfdocument/2715/16 "2021-07-22T16:17:59Z")

</div>

Looking for a Custom Fonts in CFDocument, after reading this Topic, I found a new CFDocument new option “fontdirectory”. This can be a folder mapped to Lucee Admin.  
More info here [\<cfdocument\> :: Lucee Documentation](https://docs.lucee.org/reference/tags/document.html)  
Great!  
D
