Configuring SimHei Font for Chinese Characters

This section provides a tutorial example on how to configure RenderX XEP with SimHei font family to support Chinese characters.

Now let's see how we can add configuration settings for a new font to RenderX XEP. The goal is to add a font to support Chinese characters.

1. Run Windows Character Map tool to find a font that support Chinese characters:

C:\herong>charmap

2. On the Character Map window, select "SimHei" from the font dropdown list. Then scroll down on the character list to confirm Chinese characters are supported.

3. Locate the SimHei font file:

C:\herong>dir \windows\Fonts\sim*.*

06/10/2009  05:25 PM        10,576,012 simfang.ttf
06/10/2009  05:25 PM         9,751,960 simhei.ttf
06/10/2009  05:25 PM        11,785,184 simkai.ttf
06/10/2009  05:25 PM           116,376 simpbdo.ttf
06/10/2009  05:25 PM           104,884 simpfxo.ttf
06/10/2009  05:25 PM           124,628 simpo.ttf
06/10/2009  05:25 PM        15,323,200 simsun.ttc
06/10/2009  05:25 PM        15,406,288 simsunb.ttf

4. Open RenderX XEP configuration file \proga~1\RenderX\XEP\xep.xml. Then add the following settings to define SimHei font family:

<fonts ...>
...
<font-group xml:base="file:/C:/Windows/Fonts/" 
 label="Windows TrueType" embed="true" subset="true">
 <font-family name="Arial">
  ..
  <font-family name="SimHei" embed="true">
   <font><font-data ttf="simhei.ttf"/></font>
   <font style="italic"><font-data ttf="simhei.ttf"/></font>
   <font weight="bold"><font-data ttf="simhei.ttf"/></font>
   <font weight="bold" style="italic">
    <font-data ttf="simhei.ttf"/>
   </font>
  </font-family>
 </font-family>
</font-group>
</fonts>

5. Use the following tutorial example, RenderX-XEP-SimHei-Chinese-Font.fo, to verify the configuration:

<?xml version="1.0" encoding="utf-8"?>
<!-- RenderX-XEP-SimHei-Chinese-Font.fo
 - Copyright (c) 2016, HerongYang.com, All Rights Reserved.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="page" 
   margin="0.1in" page-height="4.4in" page-width="3.4in">
   <fo:region-body region-name="body"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="body" font-size="10pt">
<fo:block margin-top="6pt">English letters:
 <fo:inline background-color="#ffddff" 
  font-family="sans-serif" font-weight="bold">
The tangram is a dissection puzzle consisting of seven flat shapes, 
called tans, which are put together to form shapes.
 </fo:inline>
</fo:block>
<fo:block margin-top="6pt">Chinese characters:
 <fo:inline background-color="#ffddff" 
  font-family="SimHei" font-weight="bold">
七巧板是一種智力游戏,顧名思義,七巧板是由七塊板組成的。由於等積變換,
所以這七塊板可拼成許多圖形(千種以上)。
 </fo:inline>
</fo:block>
  </fo:flow>
 </fo:page-sequence>
</fo:root>

If you process this example XSL-FO document with RenderX XEP tool to generate a PDF file, you will see no errors. If you open the PDF output file, Chinese characters are formatted correctly:

RenderX XEP Output with SimHei Chinese Font

Notice that I used font-weight="bold", but Chinese characters in the output are not really bolded. This is because I defined the bold font to go to the normal font file, simhei.ttf, in xep.xml. I need to find the SimHei bold font file to fix the problem.

Last update: 2016.

Table of Contents

 About This XSL-FO Tutorial Book

 Introduction of XSL-FO

 Apache™ FOP (Formatting Objects Processor)

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

 XSL-FO Document Basics and Examples

 Page Layout Masters

 Block-Level Formatting Objects

 Inline-Level Formatting Objects

 Including Graphics in XSL-FO document

 Table of Rows and Columns

 List, Item, Label, and Body

 Floating Blocks - "float" and "footnote"

 Hyperlinks, Table of Contents and Indexes

 Headers and Footers using "static-content"

 Font Attributes and Font Families

 Apache FOP Font Configurations

RenderX XEP Font Configurations

 XEP Font Configuration Settings

 XEP Predefined Font Test

Configuring SimHei Font for Chinese Characters

 References

 PDF Printing Version