Displaying Unicode characters in PDF produced by Apache FOP
<p>I have an XML file containing a list of names, some of which use characters/glyphs which are not represented in the default PDF font (Helvetica/Arial):</p>

<pre><code>&lt;name&gt;Paul&lt;/name&gt;
&lt;name&gt;你好&lt;/name&gt;
</code></pre>

<p>I'm processing this file using XSLT and Apache FOP to produce a PDF file which lists the names. Currently I'm getting the following warning on the console and the Chinese characters are replaced by ## in the PDF:</p>

<pre><code>Jan 30, 2016 11:30:56 AM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "你" (0x4f60) not available in font "Helvetica".
Jan 30, 2016 11:30:56 AM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "好" (0x597d) not available in font "Helvetica".
</code></pre>

<p>I've looked at the documentation and it seems to suggest that the options available are:</p>

<ol>
<li>Use an OpenType font - except this isn't supported by FOP.</li>
<li>Switch to a different font just for the non-ASCII parts of text.</li>
</ol>

<p>I don't want to use different fonts for each language, because there will be PDFs that have a mixture of Chinese and English, and as far as I know there's no way to work out which is which in XSLT/XSL-FO.</p>

<p>Is it possible to embed a single font to cover all situations? At the moment I just need English and Chinese, but I'll probably need to extend that in future.</p>

<p>I'm using Apache FOP 2.1 and Java 1.7.0_91 on Ubuntu. I've seen some earlier questions on a similar topic but most seem to be using a much older version of Apache FOP (e.g. 0.95 or 1.1) and I don't know if anything has been changed/improved in the meantime.</p>

<p><strong>Edit:</strong> My question is different (I think) to the suggested duplicate. I've switched to using the <a href="http://font.ubuntu.com/" rel="nofollow">Ubuntu Font Family</a> using the following code in my FOP config:</p>

<pre><code>&lt;font kerning="yes" embed-url="../fonts/ubuntu/Ubuntu-R.ttf" embedding-mode="full"&gt;
   &lt;font-triplet name="Ubuntu" style="normal" weight="normal"/&gt;
&lt;/font&gt;

&lt;font kerning="yes" embed-url="../fonts/ubuntu/Ubuntu-B.ttf" embedding-mode="subset"&gt;
   &lt;font-triplet name="Ubuntu" style="normal" weight="bold"/&gt;
&lt;/font&gt;
</code></pre>

<p>However, I'm still getting the 'glyph not available' warning:</p>

<pre><code>Jan 31, 2016 10:22:59 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "你" (0x4f60) not available in font "Ubuntu".
Jan 31, 2016 10:22:59 AM org.apache.fop.events.LoggingEventListener processEvent
WARNING: Glyph "好" (0x597d) not available in font "Ubuntu".
</code></pre>

<p>I know Ubuntu Regular has these two glyphs because it's my standard system font.</p>

<p><strong>Edit 2:</strong> If I use <a href="http://unifoundry.com/unifont.html" rel="nofollow">GNU Unifont</a>, the glyphs display correctly. However, it seems to be a font aimed more at console use than in documents.</p>