Skip to content

FOP-2651: Share loaded fonts between renderings in the PNG and TIFF renderers (cache-fonts)Font cache - #138

Open
stn48 wants to merge 2 commits into
apache:mainfrom
stn48:font-cache
Open

stn48 wants to merge 2 commits into
apache:mainfrom
stn48:font-cache

Conversation

@stn48

@stn48 stn48 commented Nov 26, 2026

Copy link
Copy Markdown

Fixes FOP-2651. Details and measurements are on the ticket.

  • Local file: fonts are given to Java as files (Font.createFont(int, File)), so no temporary copies are made in java.io.tmpdir. This applies to all renderers that use ConfiguredFontCollection.
  • Fixes the size check in CustomFontMetricsMapper.getFont(int), which compared millipoints with points (separate commit).
  • New cache-fonts attribute on <fonts> for PNG and TIFF (default false): the configured fonts are loaded once per FopFactory and output format and shared between renderings. The code paths that become shared are made thread-safe. Fonts that Java replaces by its default font are detected and loaded again.

With 30 configured fonts, PNG output goes from 11.6 to 97 documents per second on one thread and from 13.8 to 393 on 8 threads. Memory allocation per document drops from 122 MB to 5.3 MB.

getFont(int) gets the font size in millipoints, but compared it with the cached size in points, so the check never matched and every call derived a new java.awt.Font. Compare in points.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant