Allow invalid coverage tables. #476
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request improves font table parsing robustness by allowing graceful handling of invalid or unexpected table formats, matching the behavior of established font rendering engines like Harfbuzz. This prevents exceptions when processing real-world fonts with non-standard table formats.
Key Changes
- Modified
CoverageTableandAnchorTableto return empty table instances instead of throwing exceptions when encountering unknown format values - Added regression tests for issues #468 and #470 to verify complex scripts and problematic fonts render without exceptions
- Refactored existing test code in
Issues_469to retrieve font names dynamically after adding them to collections
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/SixLabors.Fonts/Tables/AdvancedTypographic/CoverageTable.cs |
Added EmptyCoverageTable singleton to handle unknown coverage formats gracefully instead of throwing exceptions |
src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/AnchorTable.cs |
Renamed EmptyAnchor to EmptyAnchorTable and converted to singleton pattern for consistency |
tests/SixLabors.Fonts.Tests/TestFonts.cs |
Added new test font file paths for regression tests (NotoSansArabic, Consola, SofiaSansCondensed) |
tests/SixLabors.Fonts.Tests/Issues/Issues_468.cs |
New regression test for issue #468 verifying Arabic text rendering with fallback fonts |
tests/SixLabors.Fonts.Tests/Issues/Issues_469.cs |
Refactored to retrieve font names dynamically from collection instead of using hardcoded constants |
tests/SixLabors.Fonts.Tests/Issues/Issues_470.cs |
New regression test for issue #470 verifying multi-script text rendering with SofiaSans font |
tests/Images/ReferenceOutput/Test_Issue_470-.png |
Reference output image for issue #470 test |
tests/Images/ReferenceOutput/TestIssue_468-.png |
Reference output image for issue #468 test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
This was referenced May 12, 2026
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.
Prerequisites
Description
Fixes #470 Fixes #468
This pull request improves the handling of invalid or unexpected font table formats in the font rendering engine, ensuring better compatibility with real-world fonts and preventing exceptions. It also adds new regression tests for recent issues and minor refactoring in test code for clarity and maintainability.
Robustness and Compatibility Improvements:
CoverageTablenow gracefully handles unknowncoverageFormatvalues by returning an empty table instead of throwing an exception, matching Harfbuzz's behavior and fixing issues with fonts like SofiaSans Condensed. An internalEmptyCoverageTableclass was added for this purpose. [1] [2]AnchorTableuses a more descriptiveEmptyAnchorTableidentifier and continues to treat unknown anchor formats as empty, in line with Harfbuzz and FontKit, improving handling of fonts like NotoSans Regular. [1] [2]Testing and Regression Coverage:
TestFontsutility to include additional font files required for new tests.Test Code Refactoring:
Issues_469test by retrieving font names after adding to the collection, improving clarity and reducing the risk of mismatches. [1] [2]