What Are FOP Generic Font Families


What are generic font families used in FOP?

✍: FYIcenter.com


FOP supports 3 generic font families:

  • "serif" - Generic font family for Times, Times Roman, and similar fonts.
  • "sans-serif" - Generic font family for Helvetica, Arial, and similar fonts.
  • "monospace" - Generic font family for Courier, New Courier, and similar fonts.

Here is how you can test this:

1. Create a FO file, generic-fonts.fo:

<?xml version="1.0" encoding="utf-8"?>
<!-- generic-fonts.fo
     Copyright (c) 2018 FYIcenter.com
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:simple-page-master master-name="myPage">
      <fo:region-body margin="1in"/>
  <fo:page-sequence master-reference="myPage">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>Default font: Welcome to jar.FYIcenter.com!</fo:block>
      <fo:block font-family="serif">serif: Welcome to jar.FYIcenter.com!</fo:block>
      <fo:block font-family="sans-serif">sans-serif: Welcome to jar.FYIcenter.com!</fo:block>
      <fo:block font-family="monospace">monospace: Welcome to jar.FYIcenter.com!</fo:block>

2. Generate the PDF output from this FO file.

\local\fop-2.2\fop>fop \fyicenter\generic-fonts.fo \temp\generic-fonts.pdf
org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.

3. View the output PDF file, generic-fonts.pdf, Adobe Acrobat Reader. Click "File > Properties" to open the properties screen. Then click the "Fonts" tab. You see the font information

   Type: Type 1
   Encoding: Ansi
   Actual Font: CourierStd
   Actual Font Type: Type 1

   Type: Type 1
   Encoding: Ansi
   Actual Font: ArialMT
   Actual Font Type: TrueType

   Type: Type 1
   Encoding: Ansi
   Actual Font: TimesNewRomanPSMT
   Actual Font Type: TrueType

Note that how Acrobat Reader maps generic fonts to their own fonts:

serif      > Times-Roman
sans-serif > Helvetica
monospace  > Courier

The picture below shows you generic fonts used in the PDF file generated from FOP:
FOP Generic Fonts for PDF

This tutorial is valid in FOP 2.2, 2.1, and 2.0.


FOP Base-14 Fonts for PDF

The Default Font used by FOP

Managing Fonts in FOP PDF Output

⇑⇑ FAQ for FOP (Formatting Object Processor)

2018-04-21, 139👍, 0💬