Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
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, 1621🔥, 0💬
Popular Posts:
How to show the XML parsing flow with sax\DocumentTracer.java provided in the Apache Xerces package?...
pache Derby is an open source relational database implemented entirely in Java and available under t...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.0.2? The if y...
How to show the XML parsing flow with sax\DocumentTracer.java provided in the Apache Xerces package?...
JDK 11 java.management.jmod is the JMOD file for JDK 11 Management module. JDK 11 Management module ...