-
-
Notifications
You must be signed in to change notification settings - Fork 43
Support rendering painted layered glyphs. #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements support for rendering painted/layered glyphs (e.g., color emoji fonts) by introducing multi-layer glyph rendering capabilities, new gradient brush types, and enhanced text decoration handling.
- Adds
GlyphPathCollectionAPI to preserve layer boundaries and metadata for painted glyphs - Introduces
SweepGradientBrushand enhancesLinearGradientBrush/RadialGradientBrushfor COLRv1/SVG font support - Refactors text decoration rendering to fix gaps and alignment issues
Reviewed Changes
Copilot reviewed 56 out of 57 changed files in this pull request and generated 24 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ImageSharp.Drawing/Shapes/Text/GlyphPathCollection.cs | New class to store per-glyph paths with layer metadata |
| src/ImageSharp.Drawing/Shapes/Text/BaseGlyphBuilder.cs | Refactored to capture layered glyph data via BeginLayer/EndLayer |
| src/ImageSharp.Drawing/Processing/SweepGradientBrush.cs | New sweep gradient brush for conic gradients |
| src/ImageSharp.Drawing/Processing/RadialGradientBrush.cs | Enhanced to support two-circle gradients |
| src/ImageSharp.Drawing/Processing/LinearGradientBrush.cs | Enhanced to support three-point rotated gradients |
| src/ImageSharp.Drawing/Processing/Extensions/FillPathCollectionExtensions.cs | New Fill overloads for rendering multi-layer glyphs with heuristics |
| src/ImageSharp.Drawing/Processing/Processors/Text/RichTextGlyphRenderer.cs | Refactored to support layer rendering and paint-to-brush conversion |
| src/ImageSharp.Drawing/Shapes/Text/TextBuilder.cs | New GenerateGlyphs API returning per-glyph collections |
| src/ImageSharp.Drawing/Shapes/PathExtensions.cs | Added ComputeArea methods for path area calculation |
| src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | Updated dependency versions for SixLabors.Fonts and ImageSharp |
| tests/ImageSharp.Drawing.Tests/Issues/Issue_462.cs | New test cases for emoji font rendering |
| tests/Images/ReferenceOutput/Issue_462/*.png | Reference images for painted glyph tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Prerequisites
Description
See SixLabors/Fonts#462 for requirements.
This pull request introduces several improvements and updates to the ImageSharp.Drawing library, focusing on enhanced glyph filling capabilities, gradient brush flexibility, dependency updates, and minor code cleanups. The most significant changes are the addition of advanced glyph fill methods, a more flexible linear gradient brush supporting rotated gradients, and updates to package dependencies.
Glyph Filling Enhancements
FillPathCollectionExtensionsthat allow filling and stroking multi-layer glyphs using a heuristic to decide per-layer fill or stroke, supporting advanced typography and painted glyphs. This includes support for custom layer fill decisions and improved documentation.RichTextGlyphRendererandBaseGlyphBuilderto support newIGlyphRendererversion fromSixLabors.Fontswhich allows rendering layered (painted) glyphs. In addition, inheritance was improved to ensure consistency with captured paths and rendered output.Gradient Brush Improvements
LinearGradientBrushto support both classic two-point and three-point (rotated) gradients, allowing more flexible and expressive gradient fills. Improved constructor signatures and documentation for clarity.SweepGradientBrushto support sweep gradients required by COLRv1 Fonts.RadialGradientBrushto support two circle gradients to support COLRv1 and SVG FontsDependency and Environment Updates
ImageSharp.Drawing.csprojto newer alpha versions ofSixLabors.FontsandSixLabors.ImageSharpfor improved compatibility and features.Codebase Cleanups and Minor Fixes
ClearExtensions.csfor consistency with current APIs.EllipticGradientBrush.csby removing unnecessary class qualification.These changes collectively improve the library's capabilities for advanced text rendering, gradient painting, and developer experience.
Examples.
The following images demonstrate the new layered glyph rendering capabilities:
The first image renders the glyphs as rich text using the full capabilities of the renderer to draw a combination of gradients and fills using the
DrawTextAPI. Pens are configured to customize the stroke lines for text decorations. Note consistency of decorations across glyphs now matches browser behaviour.The second image demonstrates the new rendering capabilities when filling the collection of glyphs using the
TextBuilder + FillAPI. Heuristics are used based on captured metadata to determine areas to fill vs areas to draw on painted (layerd) glyphs. Decorations are rendered using the values captured from font metrics.