Repository navigation
Embedded subset fonts and fallback chains in SVG export - #2629
Merged
Merged
Conversation
…, per-font glyph fallback spans
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Embedded subset fonts and fallback chains in SVG export
Summary
Shapes and charts exported to SVG now render with the same fonts the text was measured with, in any browser, independent of the fonts installed on the viewer's machine.
Fonts
SvgRenderOptions.EmbedFonts, defaulttrue): fonts are embedded as subsets via@font-face. Only fonts with an open licence (OFL, Apache, Ubuntu, Bitstream Vera) and fonts bundled with EPPlus are embedded by default. Commercial fonts are referenced by name, followed by an embedded safety net (ultimately Archivo Narrow).OnFontEmbeddingcan override this per font, usingFontEmbeddingInfo.Target.font-familylists the measured font, glyph fallbacks with their script chains, the fallback chain and a generic family. Glyph fallbacks written by name get their owntspan, so browsers cannot pick a different font for those characters.SubsetOptions.RemoveHintingremovescvt/fpgm/prep, glyph instructions and the maxp hinting limits, producing a valid unhinted font. A three-kana BIZ UDGothic subset shrinks from ~8.5 kB to ~3 kB. PDF export is unchanged.Robustness against host pages
.epplus-svg text, .epplus-svg tspan { … !important }) protects kerning, ligatures, spacing and synthesis from host CSS.textLengthkeeps each run at its measured width.Fixes
Tests
SvgBrowserCheckTests.WriteBrowserCheckPage(categoryManual) writes a visual check page. Verified in Chrome, Edge and Firefox. Safari/WebKit pending.