Configuring JasperReports Server for Multibyte 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 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.

    Procedure
  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 in the file system.

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/actual_size.<ver>.jrxml

Property

Value

Description

style name=
    "ChartLegend"
fontName=

"fontName="
<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 actual_size.<ver>.jrxml file and importing the modified file into JasperReports Server, you must create new Ad Hoc reports for charts that contain Asian characters using the modified report template.

If Japanese fonts are not installed in the server machine, you can install them and create a custom report template to support them in the following manner:

    Procedure
  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. Log into JasperReports Server as an administrator and export the Actual Size template from the Public > Templates folder in the repository. The procedures for exporting and importing a template are described in the JasperReports Server Ultimate Guide.
  4. In the exported file folder, find resources/public/templates/actual_size.<ver>.jrxml.data and rename the file to remove the .data extension.
  5. Open actual_size.<ver>.jrxml to edit it.
  6. Locate the following line:
    style name="ChartLegend" ... fontName="DejaVu Sans"
    Modify the line as follows:
    fontName="SansSerif"
  7. In JasperReports Server, browse to the Public > Templates folder in the repository.
  8. Right-click the Templates folder and select Add Resource > File > JRXML from the context menu to import the edited actual_size.<ver>.jrxml file as a new custom report template.

You can use the new custom report template for charts that contain Asian characters.

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

    Procedure
  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
  1. 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
  1. Save the file.
  2. Restart JasperReports Server.

Embedding Fonts in PDF Output for OLAP Views

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, 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 export OLAP views 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. To keep memory requirements small, we recommend you use the smallest font file you can, such as SimHei to support Chinese, Japanese, and Korean.