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 Missing Italic and Bold Fonts for PDF
Why I am getting the 'Font "Calibri,normal,700" not found. Substituting with "Calibri,normal,400"' error with FOP?
✍: FYIcenter.com
You are getting the "Font X,normal,700 not found. Substituting with X,normal,400" error,
if FOP can not find the "Bold" font definition for the font X.
Computer fonts are usually defined as a family of minimum 4 fonts: Normal, Bold, Italic and Bold-Italic. So that you can the font in 4 variations as shown in this FO file, calibri-bold-italic.fo:
<?xml version="1.0" encoding="utf-8"?> <!-- calibri-bold-italic.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"> <fo:block font-family="Calibri">Calibri: Welcome to jar.FYIcenter.com!</fo:block> <fo:block font-family="Calibri" font-weight="bold"> Calibri Bold: Welcome to jar.FYIcenter.com!</fo:block> <fo:block font-family="Calibri" font-style="italic"> Calibri Italic: Welcome to jar.FYIcenter.com!</fo:block> <fo:block font-family="Calibri" font-weight="bold" font-style="italic"> Calibri Bold and Italic: Welcome to jar.FYIcenter.com!</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
If you try to generate the PDF output with only the normal "Calibri" font defined, you will get errors as shown below:
\local\fop-2.2\fop>fop \fyicenter\calibri-bold-italic.fo \temp\calibri-bold-italic.pdf -c \fyicenter\cfg-font.xml org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Calibri,normal,700" not found. Substituting with "Calibri,normal,400". org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Calibri,italic,400" not found. Substituting with "Calibri,normal,400". org.apache.fop.events.LoggingEventListener processEvent WARNING: Font "Calibri,italic,700" not found. Substituting with "Calibri,normal,400". org.apache.fop.events.LoggingEventListener processEvent INFO: Rendered page #1.
Notice that how a font is identified with 3 parameters: font family name, style and weight. For example, "Calibri,normal,700" identifies the "normal" style font with "700 (bold)" weight from the "Calibri" font family.
To resolve the issue, we need to build 3 more font definition files for "Calibri Bold", "Calibri Italic", and "Calibri Italic Bold".
This tutorial is valid in FOP 2.2, 2.1, and 2.0.
⇒ FOP TTFReader - Build Italic and Bold Fonts
⇐ Define Your Own Font in FOP cfg.xml
2018-04-12, 1979🔥, 0💬
Popular Posts:
JDK 11 java.management.jmod is the JMOD file for JDK 11 Management module. JDK 11 Management module ...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was develo...
XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with ...
JDK 11 jdk.jlink.jmod is the JMOD file for JDK 11 JLink tool, which can be invoked by the "jlink" co...
How to download and install JDK (Java Development Kit) 6? If you want to write Java applications, yo...