Skip to content

Add font fallback resolver and update submodules - #555

Merged
JimBobSquarePants merged 2 commits into
mainfrom
js/font-fallback-resolver
Aug 11, 2026
Merged

Add font fallback resolver and update submodules#555
JimBobSquarePants merged 2 commits into
mainfrom
js/font-fallback-resolver

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
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

This pull request introduces a new extensible fallback mechanism for font shaping, allowing users to provide a custom IFontFallbackResolver to resolve glyphs for code points that cannot be shaped by the primary or fallback font families. The system includes a built-in resolver that leverages the operating system's installed fonts, and the shaping pipeline is updated to consult the resolver as a last resort. Comprehensive tests are added to validate the new fallback behavior.

Font Fallback Extensibility and Pipeline Updates:

  • Introduced the IFontFallbackResolver interface, which allows custom logic for resolving font families for code points not covered by configured fonts (src/SixLabors.Fonts/IFontFallbackResolver.cs).
  • Added the FontFallbackResolver property to TextOptions, enabling users to specify a resolver for unresolved code points, and ensured it is copied in constructors and utilities (src/SixLabors.Fonts/TextOptions.cs, tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs). [1] [2] [3]
  • Updated the shaping pipeline to consult the resolver after all configured fonts and fallbacks have been tried, and to shape with any new families returned by the resolver (src/SixLabors.Fonts/TextShaper.Pipeline.cs). [1] [2] [3] [4] [5] [6]

Built-in System Resolver:

  • Implemented SystemFontFallbackResolver, a built-in resolver that uses the OS's font matching to resolve families, with caching for performance, and exposed it as SystemFonts.FallbackResolver (src/SixLabors.Fonts/SystemFontFallbackResolver.cs, src/SixLabors.Fonts/SystemFonts.cs). [1] [2]

Testing and Dependency Updates:

  • Added comprehensive tests for the fallback resolver, covering cases such as successful resolution, resolver not consulted when not needed, explicit fallback taking precedence, non-covering families, and resolver failure (tests/SixLabors.Fonts.Tests/FontFallbackResolverTests.cs).
  • Updated test project dependencies and enabled drawing support (tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj). [1] [2]

Submodule Updates:

  • Updated the shared-infrastructure and harfbuzz submodules to new commits. [1] [2]

Introduce `IFontFallbackResolver` and expose `SystemFonts.FallbackResolver` so text shaping can ask a resolver for a fallback family after the primary and explicit fallback fonts fail. The shaping pipeline now retries unresolved code points with resolver-supplied families, carries the option through cloned layout settings, and adds focused tests covering resolver use, precedence, caching behavior, and missing-glyph fallback.
Bumps the `shared-infrastructure` and `tests/harfbuzz` submodules to newer commits so the repository picks up the latest shared infrastructure and HarfBuzz test data changes.
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 81%. Comparing base (7e13fdf) to head (29308d4).

Files with missing lines Patch % Lines
src/SixLabors.Fonts/SystemFontFallbackResolver.cs 0% 9 Missing ⚠️
src/SixLabors.Fonts/SystemFonts.cs 50% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main    #555    +/-   ##
======================================
  Coverage     81%     81%            
======================================
  Files        405     406     +1     
  Lines      35612   35672    +60     
  Branches    5548    5561    +13     
======================================
+ Hits       28931   29145   +214     
+ Misses      5485    5358   -127     
+ Partials    1196    1169    -27     
Flag Coverage Δ
unittests 81% <83%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JimBobSquarePants
JimBobSquarePants merged commit 812fd6f into main Aug 11, 2026
12 checks passed
@JimBobSquarePants
JimBobSquarePants deleted the js/font-fallback-resolver branch August 11, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant