#715: FontMap.java

projectforge-business/src/main/java/org/projectforge/framework/renderer/FontMap.java Font Loader for PDF Rendering, projectforge-business/src/main/java/org/projectforge/framework/renderer/FontMap.java 65 lines · 33 code · 26 comments · 6 blank
Loads AFM (Adobe Font Metrics) font files from a directory into a map keyed by PostScript font name. Used by the FOP/XSL-FO PDF rendering pipeline to provide embeddable fonts.

Architecture

FontMap maintains an internal Map<String, BaseFont> (HashMap) that maps PostScript font names to iText BaseFont objects. The single public method loadFonts(File fontDir) recursively scans the given directory for .afm files and loads each one.

Loading Process

  1. Uses FileUtils.listFiles(fontDir, ["afm"], true) to recursively collect all AFM files.
  2. For each file, calls BaseFont.createFont(path, BaseFont.CP1252, BaseFont.EMBEDDED) to create an iText font with CP1252 encoding and embedding enabled.
  3. Extracts the PostScript font name via font.getPostscriptFontName() and stores it in the map.
  4. Errors during font loading (e.g., corrupt file) are logged via SLF4J and the problematic font is skipped (via continue).

Key Details

Dependencies

Git History

868d6abb7 2026-01-01 2025 -> 2026
63081666f 2025-01-01 Source file headers: 2024-> 2025.
b6092df09 2024-01-09 Copyright 2023 -> 2024
ab45d51fa 2023-01-01 Copyright 2001-2022 -> 2001-2023.
73b0be50b 2022-12-06 org.apache.commons.collections -> org.apache.commons.collections4
c06db1dab 2022-04-21 Nearly all jars updated (code changes required).
5f7ef41b8 2022-02-18 Copyright 2021 -> 2022
ceb63e8a1 2021-03-08 Source code header: (C) 2001-2021.
7c79f1922 2020-01-03 Copyright of source header -> 2020.
73a9755df 2019-10-11 More code cleanup: - Collapsed catch blocks ...
32f634b88 2019-10-09 Optimize imports
000ca723d 2019-10-07 Remove pointless boolean expressions (business)
dd5ca38ac 2019-06-07 CopyRight of all java file-header updated or created.
a5bbdca6a 2017-12-04 Change logger to slf4j
9ebb88522 2016-07-18 Initial commit