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:
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, ∼1673🔥, 0💬
Popular Posts:
What Is commons-io-2.11.jar? commons-io-2.11.jar is the JAR file for Commons IO 2.5, which is a libr...
How to download and install JDK (Java Development Kit) 5? If you want to write Java applications, yo...
JDK 17 java.rmi.jmod is the JMOD file for JDK 17 RMI (Remote Method Invocation) module. JDK 17 RMI m...
JDK 17 jdk.localedata.jmod is the JMOD file for JDK 17 Localedata module. JDK 17 Locale Data module ...
JDK 11 jdk.internal.le.jmod is the JMOD file for JDK 11 Internal Line Editing module. JDK 11 Interna...