Fix interpreter issues and prevent multple kerning operations#489
Merged
JimBobSquarePants merged 4 commits intomainfrom Dec 1, 2025
Merged
Fix interpreter issues and prevent multple kerning operations#489JimBobSquarePants merged 4 commits intomainfrom
JimBobSquarePants merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request addresses critical bugs in the TrueType interpreter and introduces state tracking for glyph positioning and kerning operations to prevent redundant processing. The changes improve font rendering accuracy and performance while modernizing the codebase with collection expressions.
- Fixed multiple bugs in the TrueType interpreter including incorrect point index toggling, zone pointer usage, and IUP flag setting
- Completely reimplemented the Round function to match FreeType v40's rounding semantics across all modes
- Added
IsPositionedandIsKernedflags to prevent double application of positioning and kerning operations
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/SixLabors.Fonts.Tests/TextLayoutTestUtilities.cs | Added customDecorations parameter to control test decoration pens conditionally |
| tests/SixLabors.Fonts.Tests/TestFonts.cs | Added Tahoma font path for hinting tests |
| tests/SixLabors.Fonts.Tests/Issues/Issues_462.cs | Updated test calls to pass customDecorations: true |
| tests/SixLabors.Fonts.Tests/ImageComparison/TestImageExtensions.cs | Added PNG encoder with optimal compression settings for test output |
| tests/SixLabors.Fonts.Tests/HintingTests.cs | New robustness tests for TrueType hinting with Arial, Tahoma, and OpenSans |
| tests/Images/ReferenceOutput/*.png | Reference output images for hinting tests (Git LFS tracked) |
| src/SixLabors.Fonts/TextLayout.cs | Optimized to skip redundant UpdatePositions calls for consecutive runs with same font |
| src/SixLabors.Fonts/Tables/TrueType/Hinting/TrueTypeInterpreter.cs | Fixed bugs in OnCurve toggling, IUP flag setting, zone pointer usage, and twilight zone detection; reimplemented Round function |
| src/SixLabors.Fonts/Tables/General/Kern/KerningTable.cs | Added kerning state check and modernized with collection expressions |
| src/SixLabors.Fonts/Tables/General/Kern/KerningSubTable.cs | Removed var keyword for explicit type declaration |
| src/SixLabors.Fonts/Tables/General/Kern/Format0SubTable.cs | Improved comment formatting and removed var keyword |
| src/SixLabors.Fonts/GlyphShapingData.cs | Added IsPositioned and IsKerned properties with copy constructor support |
| src/SixLabors.Fonts/GlyphPositioningCollection.cs | Integrated IsPositioned flag setting and checking to prevent redundant processing |
💡 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 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
This pull request introduces several important improvements and bug fixes to the font rendering engine, focusing on glyph positioning, kerning, and TrueType hinting. The changes enhance correctness, efficiency, and maintainability, particularly in the handling of glyph state and the implementation of the TrueType interpreter. Additionally, some code modernizations and new test reference images are included.
Glyph Positioning and Kerning Improvements
IsPositioned) and kerning (IsKerned) states inGlyphShapingData, preventing redundant processing and ensuring accurate state propagation during glyph shaping and kerning. The kerning logic now checks and setsIsKernedto avoid double application.TextLayoutby avoiding redundant updates for consecutiveTextRuns using the same font.TrueType Interpreter Bug Fixes and Enhancements
TrueTypeInterpreter, including:OnCurveflag for the correct point index.iupXCalledflag in the IUP instruction.Roundfunction to precisely match FreeType v40's rounding semantics, ensuring correct and consistent rendering across all rounding modes.Documentation and Code Modernization
TrueTypeInterpreter, detailing the reference model and behavioral expectations for modern and legacy fonts.Testing