FOP Missing Italic and Bold Fonts for PDF

Q

Why I am getting the 'Font "Calibri,normal,700" not found. Substituting with "Calibri,normal,400"' error with FOP?

✍: FYIcenter.com

A

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
-->
<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
org.apache.fop.events.LoggingEventListener processEvent
org.apache.fop.events.LoggingEventListener processEvent