• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pdfcpu / pdfcpu / 18786914678
62%

Build:
DEFAULT BRANCH: master
Ran 24 Oct 2025 05:14PM UTC
Jobs 2
Files 198
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

24 Oct 2025 05:12PM UTC coverage: 62.337% (-0.01%) from 62.349%
18786914678

push

github

hhrutter
Implement lazy font loading to reduce memory footprint

This change defers font loading until fonts are actually needed, reducing
memory usage for operations that don't require fonts (merge, split, etc.).

Changes:
- pkg/font/metrics.go: Add lazy loading with sync.Once pattern
  - doLoadUserFonts(): Actual loading implementation
  - LoadUserFonts(): Idempotent wrapper using sync.Once
  - ensureUserFontsLoaded(): Convenience wrapper for error-free calls
- pkg/pdfcpu/model/configuration.go: Replace eager font loading with
  ensureFontDirInitialized() that only sets up directories

Design:
- Uses sync.Once for clean, idiomatic lazy initialization
- Separates loading synchronization (Once) from map access (RWMutex)
- Error from first load attempt is cached and returned to all callers
- Thread-safe and efficient (atomic operations in sync.Once)

Benefits:
- Reduces minimum virtual memory requirement from ~800MB to ~720MB
- Eliminates unnecessary 16MB font allocation for common operations
- No impact on operations that need fonts (loaded on first use)
- Improves startup time when fonts aren't needed

Testing:
- Operations without fonts (merge, split, validate) now work with 720MB VSZ
- Operations with fonts (stamps, forms) load fonts lazily on first access
- LoadUserFonts() is idempotent and thread-safe

Related to #1169

22 of 33 new or added lines in 2 files covered. (66.67%)

9 existing lines in 1 file now uncovered.

44728 of 71752 relevant lines covered (62.34%)

3005427.14 hits per line

Uncovered Changes

Lines Coverage ∆ File
6
49.6
-3.14% pkg/pdfcpu/model/configuration.go
5
72.61
-0.31% pkg/font/metrics.go

Coverage Regressions

Lines Coverage ∆ File
9
49.6
-3.14% pkg/pdfcpu/model/configuration.go
Jobs
ID Job ID Ran Files Coverage
1 Go-1.25.x - 18786914678.1 24 Oct 2025 05:14PM UTC 198
62.34
GitHub Action Run
2 Go-1.24.x - 18786914678.2 24 Oct 2025 05:14PM UTC 198
62.34
GitHub Action Run
Source Files on build 18786914678
  • Tree
  • List 198
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 223cdb0c on github
  • Prev Build on master (#18775105030)
  • Next Build on master (#18807822718)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc