Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
4-Byte Unicode Not Supported in FOP
How to use FOP to support all Unicode characters including 4-byte Unicode characters?
✍: FYIcenter.com
If you want to use FOP to support all Unicode characters,
you can follow this tutorial:
1. Download a font file that can support all Unicode characters from https://ftp.gnu.org/gnu/unifont/unifont.
2. Selete the latest version in TTF format: unifont-10.0.07.ttf.
3. Build the font definition file:
\local\fop-2.2\fop>java -cp %FOP_PATH%\build\fop.jar; %FOP_PATH%\lib\xercesImpl-2.9.1.jar; %FOP_PATH%\lib\xalan-2.7.2.jar; %FOP_PATH%\lib\avalon-framework-4.3.1.jar; %FOP_PATH%\lib\commons-logging-1.0.4.jar; %FOP_PATH%\lib\commons-io-1.3.1.jar; %FOP_PATH%\lib\serializer-2.7.2.jar; %FOP_PATH%\lib\xmlgraphics-commons-2.2.jar org.apache.fop.fonts.apps.TTFReader -d \fyicenter\unifont-10.0.07.ttf \fyicenter\Unicode.xml
4. Create a FOP configuration file,
<?xml version="1.0"?>
<!-- cfg-unicode.xml
Copyright (c) 2018 FYIcenter.com
-->
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<fonts>
<font metrics-url="\fyicenter\Unicode.xml" kerning="yes"
embed-url="\fyicenter\unifont-10.0.07.ttf">
<font-triplet name="Unicode" style="normal" weight="normal"/>
<font-triplet name="Unicode" style="normal" weight="bold"/>
<font-triplet name="Unicode" style="italic" weight="normal"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
5. Create a test FO file, unicode-test.fo:
<?xml version="1.0" encoding="utf-8"?>
<!-- unicode-test.fo
Copyright (c) 2018 FYIcenter.com
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="myPage">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="myPage">
<fo:flow flow-name="xsl-region-body" font-family="Unicode">
<fo:block>1-Byte Unicode &#x41;: ABC</fo:block>
<fo:block>2-Byte Unicode &#x0278;: ︘ꀕ</fo:block>
<fo:block>4-Byte Unicode &#x1F60B;: 😋</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
6. Run FOP to generate the PDF output:
>\local\fop-2.2\fop\fop -c \fyicenter\cfg-unicode.xml \fyicenter\unicode-test.fo \fyicenter\unicode-test.pdf WARNING: Glyph "?" (0xd83d) not available in font "UnifontMedium". WARNING: Glyph "?" (0xde0b) not available in font "UnifontMedium". INFO: Rendered page #1.
The two warning messages are actually caused by a single issue. FOP does not support the 4-byte Unicode characters U+1F60B. It first converted the U+1F60B into two characters 0xd83d and 0xde0b, then declared that those two characters are not supported by the Unicode font.
Open the PDF file with Acrobat Reader, you see that 1-byte and 2-byte Unicode characters
are generated correctly. But the 4-byte Unicode character is not:
⇒ Download and Installing of FOP 2.x
⇐ Use Unicode Characters with FOP
2018-03-17, ∼2053🔥, 0💬
Popular Posts:
Apache Commons CLI Source Code Files are provided in the source package file commons-cli-1.5.0-sourc. ..
How to download and install Apache XMLBeans-2.6.0.zip? If you want to try the XMLBeans Java library,...
maven-core-3.5.4.jar is the JAR file for Apache Maven 3.5.4 Core module. Apache Maven is a software ...
The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible...
JDK 17 jdk.localedata.jmod is the JMOD file for JDK 17 Localedata module. JDK 17 Locale Data module ...