Do not over-apply sub-tables during contextual substitution list apply#455
Merged
JimBobSquarePants merged 1 commit intomainfrom Apr 23, 2025
Merged
Do not over-apply sub-tables during contextual substitution list apply#455JimBobSquarePants merged 1 commit intomainfrom
JimBobSquarePants merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issue #451 by ensuring that only the first applicable sub-table is processed during chained contextual substitutions and by enhancing debug tracking for applied features.
- Updated GPos lookup sub-tables and related utility methods to pass the new "feature" parameter.
- Modified ApplyLookupList methods in AdvancedTypographicUtils to always return true and removed the "hasChanged" flag.
- Added tests for issue #451 and adjusted the test fonts to include VeryBerryProRegular.
Reviewed Changes
Copilot reviewed 10 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/SixLabors.Fonts.Tests/TestFonts.cs | Added a new test font path for VeryBerryProRegular. |
| tests/SixLabors.Fonts.Tests/Issues/Issues_451.cs | Added tests to validate the fix for issue #451. |
| src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType{1,2,4,5,6}SubTable.cs | Updated calls to utility methods to include the "feature" parameter. |
| src/SixLabors.Fonts/Tables/AdvancedTypographic/AdvancedTypographicUtils.cs | Revised lookup list handling and position/anchor applications to incorporate the feature parameter. |
| src/SixLabors.Fonts/GlyphShapingData.cs | Changed AppliedFeatures from List to HashSet and updated the copying logic accordingly. |
Files not reviewed (3)
- tests/Images/ReferenceOutput/Issue_451_A-.png: Language not supported
- tests/Images/ReferenceOutput/Issue_451_B-.png: Language not supported
- tests/Images/ReferenceOutput/Issue_451_C-.png: Language not supported
Comments suppressed due to low confidence (3)
src/SixLabors.Fonts/Tables/AdvancedTypographic/AdvancedTypographicUtils.cs:74
- Changing the return value from 'hasChanged' to always returning true in ApplyLookupList might conceal cases where no position changes occurred. Please verify that this change in behavior is intended.
return true;
src/SixLabors.Fonts/Tables/AdvancedTypographic/AdvancedTypographicUtils.cs:98
- In the second overload of ApplyLookupList, the removal of the 'hasChanged' flag and always returning true may hide cases without updates. Confirm that this behavior is acceptable for all usage scenarios.
return true;
src/SixLabors.Fonts/GlyphShapingData.cs:130
- [nitpick] Switching from a List to a HashSet for AppliedFeatures may affect the order in which features are applied. Please confirm that feature order is not significant for downstream processing.
public HashSet<Tag> AppliedFeatures { get; set; } = new();
tocsoft
approved these changes
Apr 23, 2025
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 #451
When applying lookups during chained contextual substitution we were looping through all sub-tables for a given feature when we should have been returning after the first.
I've also added extra debugging issue that was missing from the positioning collection which tracked what features have been applied.