Configuring JasperReports Server for Multi-byte Fonts

Although translation packs for Chinese and Japanese ship with JasperReports Server, the fonts that it uses by default do not support those languages. Therefore, if your organization requires those fonts, you need to configure JasperReports Server for them.

While the fonts that JasperReports Server uses are generally dictated by the JRXML files that define your reports, some font configuration is required for special circumstances. For example, you can configure Jaspersoft OLAP to offer different options in the Chart Default Font field in the Chart Options dialog. But note that, in order to use a font, the font must be available to the host’s operating system. This section describes steps you may need to take, depending on the functionality you use and the locales you support.

The tasks in this section require you to edit these files:

File Name

Location

Purpose of Edits

jpivot_internal_messages.properties

WEB-INF/internal

Specifying chart fonts for Jaspersoft OLAP Community

Ja_pro_internal_messages.properties

WEB-INF/internal

Specifying chart fonts for Jaspersoft OLAP Professional and Enterprise

userConfig.xml

WEB-INF/jpivot/print

Embedding fonts in PDF

Enabling East Asian Fonts

The default configuration of the Java Runtime Environment (JRE) does not support East Asian fonts. If your locale requires such a font, you need to configure your users’ computers for the fonts and update their JRE.

To configure a Microsoft Windows computer (XP and later) for East Asian fonts:

Details of this procedure vary, depending on your version of Windows.

1. In the Control Panel, click Region and Language.
2. In the Region and Language dialog, select the Keyboards and Languages tab.
3. On the tab, install the language(s) that you need.
4. If necessary, install the related keyboard modifications.
5. Close the control panel.
6. Locate the fontconfig.properties.src file in the C:\Program Files\<JRE_directory>\lib folder.
7. In the file, locate the following line:

sequence.allfonts=alphabetic/default,dingbats,symbol

8. Change the line to include the East Asian fonts that you need, such as the following:

sequence.allfonts=alphabetic/default,dingbats,symbol,korean,japanese,chinese-ms936,chinese-ms950

9. At the end of the file, check to be sure that the fonts you selected are listed, as in the following:

filename.Gulim=gulim.TTC

If the fonts are not listed, add them.

10. Save and close the file.
11. Rename the file to fontconfig.properties

Configuring Ad Hoc Charts for Asian Fonts

The default font for the legend of an Ad Hoc chart does not support some Asian characters, such as Japanese kana glyphs. Default fonts for Ad Hoc reports are defined in the following file:

Changing Ad Hoc Chart Legend Fonts

Configuration File

.../WEB-INF/adhoc/themes/default.new.jrxml

Property

Value

Description

style name=
    "ChartLegend"
fontName=

"DejaVu Sans"
<default>

"SansSerif"

The default value, DejaVu Sans, does not include kana glyphs, and thus the legend contains blank symbols.

If the server machine has system Japanese fonts available, setting the value to SansSerif should work in most Java font configurations.

After making changes to the default.new.jrxml file, you must rerun all Ad Hoc reports that contain Japanese characters for them to appear.

If Japanese fonts are not installed in the server machine, you can add it in the following manner:

1. Package a Japanese font as a font extension JAR.
2. Add the new JAR to the WEB-INF/lib folder of the JasperReports Server WAR file.
3. Edit the default.new.jrxml file as described above to specify the new font name.
4. Redeploy JasperReports Server or restart its app server.
5. Rerun the affected reports. Reports saved from Ad Hoc should now display correctly in the Report Viewer, but the corresponding view may not display chart legends correctly within the Ad Hoc editor.

Configuring OLAP Options for Chart Default Fonts

If you implement Jaspersoft OLAP and support a locale with special font requirements, you can configure Jaspersoft OLAP to offer different options in the Chart Default Font field in the Chart Options dialog of the OLAP view. This may be necessary if you implement locales that Latin 1 doesn’t support.

An OLAP view’s Chart Options dialog includes the Chart Default Font field, which allows users to select the font to use in charts. The default options are SansSerif, Serif, and MonoSpaced. JasperReports Server reads these values from a properties file and attempts to map them to fonts available in the server host’s operating system. You can configure the server to offer different fonts if these fonts don’t support the locales you implement.

To change the Chart Default Font field’s options:

1. Save the jpivot_internal_messages.properties file with a new name that reflects the new locale. For example, for Japanese, the new file would be called jpivot_internal_messages_ja.properties.
2. Open the new file and locate the following keys:
JAJ_000_jsp.jpivot.chartpropertiesform.sansSerif=SansSerif
JAJ_000_jsp.jpivot.chartpropertiesform.serif=Serif
JAJ_000_jsp.jpivot.chartpropertiesform.monospaced=Monospaced

If you are using Jaspersoft OLAP Community Edition, the name of the file and the keys that you edit are different. For the Community Edition, open the jpivot_internal_message.properties file and edit these keys:

jsp.wcf.chart.sansserif=SansSerif
jsp.wcf.chart.serif=Serif
jsp.wcf.chart.monospaced=Monospaced
3. Change one or more of the strings to the name of a font available in the host’s operating system. For example, if you wanted to change the SansSerif font to the SimHei font, edit the value specified by jsp.wcf.chart.sansserif. For example:
jsp.wcf.chart.sansserif=SimHei
4. Save the file.
5. Restart JasperReports Server.

Embedding Fonts in PDF Output

By default, JasperReports Server can create PDF (Portable Document Format) files with many different fonts. However, if you experience font problems in the PDF output of your reports, you may need to take the steps described in this section to make the fonts available to JasperReports Server’s XSL Formatting Object (XSL-FO) processor.

You must have distribution rights to a font in order to embed it in a PDF file.

When users save reports in PDF format, JasperReports Server generates the PDF output using Apache FOP (Formatting Objects Processor). In order for FOP to render fonts properly, you must install the font itself (for example, a TTF file) on the server host, create a font metrics file (using Apache’s org.apache.fop.fonts.apps.TTFReader utility), and update the userConfig.xml file to associate the font with its metrics. For more information, refer to the Apache FOP documentation.

You can embed any Unicode font using this procedure, though larger font files may have significantly larger memory footprints. In order to keep memory requirements small, Jaspersoft recommends that you use the smallest font file you can, such as SimHei to support Chinese, Japanese, and Korean.

Version: 
Feedback
randomness