feat: support custom font files for song titles (Closes #4) #14

Merged
shahondin1624 merged 1 commits from feature/issue-4-support-custom-font-files-fraktur into main 2026-03-17 09:54:51 +01:00

Summary\n\n- Improved PdfFontMetrics: Uses canonical/absolute paths for cache keys to avoid duplicate font loading; validates font file existence with a clear error message before attempting to load; uses BaseFont.IDENTITY_H encoding for full Unicode support (including German umlauts)\n- Added font file path resolution in SongbookPipeline: Relative font file paths in songbook.yaml are resolved against the project directory before validation and rendering\n- Added font file validation in Validator: validateConfig() now checks that all configured font files exist, producing clear error messages identifying which font role (title, lyrics, etc.) has the missing file\n- Added comprehensive tests: 7 new tests in PdfFontMetricsTest (custom font loading, umlaut rendering, cache deduplication, missing file error, bold delegation) and 4 new tests in ValidatorTest (missing/existing font file validation)\n- Documented usage: Added commented example in songbook.yaml showing how to configure a custom font file for titles\n\nCloses #4\n\n## Test plan\n\n- [x] All existing tests pass (gradle test)\n- [x] Custom font loading from TTF file works end-to-end\n- [x] German umlauts render correctly with custom font (IDENTITY_H encoding)\n- [x] Missing font file produces clear validation error\n- [x] Cache uses canonical paths to avoid duplicate font objects\n- [x] Font file paths are resolved relative to project directory\n- [x] Example config documents custom font usage"

## Summary\n\n- **Improved `PdfFontMetrics`**: Uses canonical/absolute paths for cache keys to avoid duplicate font loading; validates font file existence with a clear error message before attempting to load; uses `BaseFont.IDENTITY_H` encoding for full Unicode support (including German umlauts)\n- **Added font file path resolution in `SongbookPipeline`**: Relative font file paths in `songbook.yaml` are resolved against the project directory before validation and rendering\n- **Added font file validation in `Validator`**: `validateConfig()` now checks that all configured font files exist, producing clear error messages identifying which font role (title, lyrics, etc.) has the missing file\n- **Added comprehensive tests**: 7 new tests in `PdfFontMetricsTest` (custom font loading, umlaut rendering, cache deduplication, missing file error, bold delegation) and 4 new tests in `ValidatorTest` (missing/existing font file validation)\n- **Documented usage**: Added commented example in `songbook.yaml` showing how to configure a custom font file for titles\n\nCloses #4\n\n## Test plan\n\n- [x] All existing tests pass (`gradle test`)\n- [x] Custom font loading from TTF file works end-to-end\n- [x] German umlauts render correctly with custom font (IDENTITY_H encoding)\n- [x] Missing font file produces clear validation error\n- [x] Cache uses canonical paths to avoid duplicate font objects\n- [x] Font file paths are resolved relative to project directory\n- [x] Example config documents custom font usage"
shahondin1624 added 1 commit 2026-03-17 09:54:35 +01:00
- Improve PdfFontMetrics: use canonical path for cache key, validate
  font file existence, use absolute paths for BaseFont.createFont
- Add font file path resolution in SongbookPipeline (relative to
  project directory)
- Add font file existence validation in Validator.validateConfig
- Add end-to-end tests: custom font loading, umlaut rendering,
  cache deduplication, missing file error
- Document custom font file usage in example songbook.yaml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shahondin1624 merged commit ab91ad2db6 into main 2026-03-17 09:54:51 +01:00
shahondin1624 deleted branch feature/issue-4-support-custom-font-files-fraktur 2026-03-17 09:54:51 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shahondin1624/songbook#14