Skip to content

Conversation

@swmal
Copy link
Contributor

@swmal swmal commented Jan 29, 2026

Fonts supporting GSUB/GPOS tables (ligatures, kerning, mark-to-base, etc), subsetting. New TextShaper and TextLayoutEngine.

TextShaper

Advanced OpenType text shaping with GSUB/GPOS support. Returns shaped glyphs with positioning, ligatures, kerning, and mark placement for typography.

var font = OpenTypeFonts.GetFontData(FontFolders, "Roboto", FontSubFamily.Regular);
ITextShaper shaper = new TextShaper(font);
// Returns ShapedText (a collection of ShapedGlyphs).
ShapedText st= shaper.Shape("Test");
var taw = st.TotalAdvanceWidth;
foreach(var shapedGlyph in st.Glyphs)
{
   var gid = shapedGlyph.GlyphId;
   var xa = shapedGlyph.XAdvance;
   var cc = shapedGlyph.CharCount;
}

// memory optimized method for measurements
GlyphWidth[] gw = shaper.ShapeLight("Test", ShapingOptions.Full);

OpenTypeTextMeasurer

Implements the "old" ITextMeasurer interface. Wrapping is now the responsibility of the TextLayoutEngine (see below).

var font = OpenTypeFonts.GetFontData(FontFolders, "Roboto", FontSubFamily.Regular);
ITextShaper shaper = new TextShaper(font);
ITextMeasurer measurer = new OpenTypeFontTextMeasurer(shaper, ShapingOptions.Default);

TextLayoutEngine

High-performance text layout engine with line breaking, word wrapping, and paragraph formatting. Handles rich text with multiple fonts and styles, font metrics, advance widths, line heights, and multi-line text rendering for professional typography.

var font = OpenTypeFonts.GetFontData(FontFolders, "Roboto", FontSubFamily.Regular);
ITextShaper shaper = new TextShaper(font);
using var layoutEngine = new TextLayoutEngine(shaper);
var wrappedLines = layoutEngine.WrapText(
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eget urna at sapien facilisis placerat. Integer mollis nibh vel tincidunt metus.",
    14f,
    450,
    ShapingOptions.Full
);
double lh = layoutEngine.GetLineHeightInPoints(14);
double bl = layoutEngine.GetBaseLineInPoints(14);
double d = layoutEngine.GetDescentInPoints(14);

EPPlus.Fonts.OpenType.Tests

Contains 200+ unit tests covering reading, serialization, subsetting and text-shaping.

EPPlus.Fonts.OpenType.Benchmarks

Performance benchmarking suite for measuring text shaping, layout, and font operations. Includes benchmarks for glyph shaping speed, memory allocation, cache performance, and comparison against baseline implementations for optimization tracking.

Previous tests with benchmark functionality (measured time, etc) has been moved from the Unit test project to the new Benchmark project.

@swmal swmal self-assigned this Jan 29, 2026
@swmal swmal added the enhancement New feature or request label Jan 29, 2026
@swmal swmal added this to the EPPlus 9.0 or later milestone Jan 29, 2026
@swmal swmal moved this to In progress in Epplus Enhancements Feb 3, 2026
@swmal swmal moved this from In progress to PR Backlog in Epplus Enhancements Feb 3, 2026
@swmal swmal moved this from PR Backlog to Review In Progress in Epplus Enhancements Feb 3, 2026
@AdrianEPPlus AdrianEPPlus merged commit 3d24ea3 into develop9 Feb 3, 2026
@github-project-automation github-project-automation bot moved this from Review In Progress to Pending Release in Epplus Enhancements Feb 3, 2026
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.

3 participants