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

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:

  • CoverageTable now gracefully handles unknown coverageFormat values by returning an empty table instead of throwing an exception, matching Harfbuzz's behavior and fixing issues with fonts like SofiaSans Condensed. An internal EmptyCoverageTable class was added for this purpose. [1] [2]
  • AnchorTable uses a more descriptive EmptyAnchorTable identifier 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:

Test Code Refactoring:

  • Simplified font name handling in Issues_469 test by retrieving font names after adding to the collection, improving clarity and reducing the risk of mismatches. [1] [2]

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 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 CoverageTable and AnchorTable to 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_469 to 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.

@JimBobSquarePants JimBobSquarePants merged commit d11ff41 into main Nov 25, 2025
23 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-468 branch November 25, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidFontFileException when rendering text with valid fonts NullReferenceException when drawing text

2 participants