Skip to content

Add per-workbook RenderContext on ExcelWorkbook#2395

Merged
JanKallman merged 6 commits into
develop9from
feature/VariableFontsV1
Jun 30, 2026
Merged

Add per-workbook RenderContext on ExcelWorkbook#2395
JanKallman merged 6 commits into
develop9from
feature/VariableFontsV1

Conversation

@swmal

@swmal swmal commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Replace global font singleton with per-workbook RenderContext

Background

The SVG export pipeline for charts and shapes resolved fonts through the global OpenTypeFonts singleton. This leaked global state into the render stack, prevented per-workbook font configuration, and made test isolation difficult.

Changes

Introduces a per-workbook RenderContext (holding the font engine), owned lazily by ExcelWorkbook and threaded through the render hierarchy — DrawingRenderer, text bodies, paragraph render items, and down to LayoutSystem/TextLayoutEngine. This mirrors the ParsingContext pattern used in formula calculation.

Nodes that have a workbook (e.g. DrawingRenderer, DrawingTextBox) fetch the context from it; nodes that don't receive it via constructor. The chart branch reaches it through ChartDrawingObject.RenderContext.

Public API: Workbook.ConfigureFonts(Action<IEpplusFontConfiguration>) for users (no class/constructor knowledge required); UseFontEngine internal for tests.

Also cleans up FontAvailability: it is now a pure result enum (NotFound, FamilyOnly, Exact), with strictness moved to a separate RequireExactFont flag defaulting to false — rendering trusts the fallback chain and no longer throws on a missing theme font.

TextLayoutEngine now carries an OpenTypeFontEngine directly, removing an abstraction-breaking cast and the last singleton fallback in the layout path.

swmal and others added 3 commits June 25, 2026 16:50
…er stack; split FontAvailability into result enum plus RequireExactFont policy
… the SVG export pipeline for charts and shapes, replacing the global OpenTypeFonts singleton; split FontAvailability into a result enum plus RequireExactFont policy
@swmal swmal added the enhancement New feature or request label Jun 29, 2026
@swmal swmal added this to the EPPlus 9.0 or later milestone Jun 29, 2026
@JanKallman JanKallman merged commit 60232b5 into develop9 Jun 30, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this to Pending Release in Epplus Enhancements Jun 30, 2026
@JanKallman JanKallman deleted the feature/VariableFontsV1 branch June 30, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Pending Release

Development

Successfully merging this pull request may close these issues.

2 participants