WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

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

  • Added new overloads to FillPathCollectionExtensions that 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.
  • Refactored RichTextGlyphRenderer and BaseGlyphBuilder to support new IGlyphRenderer version from SixLabors.Fonts which allows rendering layered (painted) glyphs. In addition, inheritance was improved to ensure consistency with captured paths and rendered output.

Gradient Brush Improvements

  • Refactored LinearGradientBrush to support both classic two-point and three-point (rotated) gradients, allowing more flexible and expressive gradient fills. Improved constructor signatures and documentation for clarity.
  • Added SweepGradientBrush to support sweep gradients required by COLRv1 Fonts.
  • Refactored RadialGradientBrush to support two circle gradients to support COLRv1 and SVG Fonts

Dependency and Environment Updates

  • Updated NuGet package references in ImageSharp.Drawing.csproj to newer alpha versions of SixLabors.Fonts and SixLabors.ImageSharp for improved compatibility and features.

Codebase Cleanups and Minor Fixes

  • Removed obsolete project configuration entries from the solution file, streamlining build configuration.
  • Fixed namespace usage and parameter documentation for improved code clarity and maintainability in extension files.
  • Corrected blending mode enum usage in ClearExtensions.cs for consistency with current APIs.
  • Simplified method calls in EllipticGradientBrush.cs by 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 DrawText API. Pens are configured to customize the stroke lines for text decorations. Note consistency of decorations across glyphs now matches browser behaviour.

CanRenderEmojiFont_With_COLRv1-

The second image demonstrates the new rendering capabilities when filling the collection of glyphs using the TextBuilder + Fill API. 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.

CanRenderEmojiFont_With_COLRv1_-G-

Copy link

Copilot AI left a 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 GlyphPathCollection API to preserve layer boundaries and metadata for painted glyphs
  • Introduces SweepGradientBrush and enhances LinearGradientBrush/RadialGradientBrush for 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.

@JimBobSquarePants JimBobSquarePants merged commit 0774da7 into main Nov 17, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking enhancement New feature or request text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants