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, ∼1738🔥, 0💬
Popular Posts:
What Is jsse.jar (JDK 6) Java Secure Socket Extension? jsse.jar, Java Secure Socket Extension, is Ja...
JDK 11 jdk.jdi.jmod is the JMOD file for JDK 11 JDI (Java Debug Interface) tool. JDK 11 JDI tool com...
What Is log4j-1.2.13.jar? I got the JAR file from logging-log4j-1.2.13.zip .log4j-1.2.13.jar is the ...
Apache Commons Codec library provides implementations of common encoders and decoders such as Base64...
How to download and install ojdbc6.jar for Oracle 11g R2? ojdbc6.jar for Oracle 11g R2 is a Java 6, ...