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:
FOP TTFReader - Build Italic and Bold Fonts
How to build Italic, Bold and Italic-Bold fonts with FOP?
✍: FYIcenter.com
To build Italic, Bold and Italic-Bold fonts with FOP, we need to find their fond files in TTF format.
For example, you see "Calibri", Italic, Bold, and Italic-Bold font files located in \windows\fonts folder:
813,876 calibri.ttf > for Calibri,normal,400 851,480 calibrib.ttf > for Calibri,normal,700 856,212 calibrii.ttf > for Calibri,italic,400 902,380 calibriz.ttf > for Calibri,italic,700
You can run FOP TTFReader program to build the "Calibri" font definition files:
\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 \windows\calibri.ttf \fyicenter\calibri.xml INFO: XML font metrics file successfully created.
Run FOP TTFReader program again to build the "Calibri" Bold, Italic and Italic-Bold font definition files.
Create a new FOP configuration file, cfg-calibri.xml, to all 4 fonts in the same family:
<?xml version="1.0"?> <!-- cfg-calibri.xml Copyright (c) 2018 FYIcenter.com --> <fop version="1.0"> <renderers> <renderer mime="application/pdf"> <fonts> <font ="\fyicenter\calibri.xml" kerning="no" embed-url="\windows\fonts\calibri.ttf"> <font-triplet name="Calibri" style="normal" weight="normal"/> </font> <font metrics-url="\fyicenter\calibrii.xml" kerning="no" embed-url="\windows\fonts\calibrii.ttf"> <font-triplet name="Calibri" style="italic" weight="normal"/> </font> <font metrics-url="\fyicenter\calibrib.xml" kerning="no" embed-url="\windows\fonts\calibrib.ttf"> <font-triplet name="Calibri" style="normal" weight="bold"/> </font> <font metrics-url="\fyicenter\calibriz.xml" kerning="no" embed-url="\windows\fonts\calibriz.ttf"> <font-triplet name="Calibri" style="italic" weight="bold"/> </font> </fonts> </renderer> </renderers> </fop>
Generate the PDF output again from the FO file, calibri-bold-italic.fo. You will see no font missing error:
\local\fop-2.2\fop>fop \fyicenter\calibri-bold-italic.fo \temp\calibri-bold-italic.pdf -c \fyicenter\cfg-calibri.xml org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #1.
Open the PDF output file, calibri-bold-italic.pdf in Acrobat Reader.
You see all 4 fonts are working correctly now:
This tutorial is valid in FOP 2.2, 2.1, and 2.0.
⇒ FontView.exe - Preview Font Glyphs on Windows
⇐ FOP Missing Italic and Bold Fonts for PDF
2018-04-12, 1081👍, 0💬
Popular Posts:
What Is HttpComponents commons-httpclient-3.1.j ar?HttpComponents commons-httpclient-3.1.j aris the ...
Saxon-HE (home edition) is an open source product available under the Mozilla Public License. It pro...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
What is the jaxp\SourceValidator.jav aprovided in the Apache Xerces package? I have Apache Xerces 2....
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...