Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request improves the robustness of OpenType MarkToBase positioning (LookupType4) by allowing the ApplyAnchor method to accept nullable anchor tables, preventing errors when a base glyph lacks an anchor for a specific mark class. This aligns with the OpenType specification which permits NULL anchor offsets in BaseArray/BaseRecord structures.
Key changes:
- Made
AnchorTableparameter nullable inApplyAnchorwith appropriate null-safety guards - Added early return when anchor is null with clear explanatory comment
- Simplified ligature component conditional check for improved readability
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/SixLabors.Fonts/Tables/AdvancedTypographic/AdvancedTypographicUtils.cs |
Updated ApplyAnchor to accept nullable AnchorTable parameter and added null check with OpenType spec-compliant handling |
src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs |
Refactored variable declarations to use explicit types and simplified ligature component check |
💡 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.
src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs
Show resolved
Hide resolved
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 #479
This pull request improves the handling of OpenType MarkToBase positioning in the advanced typographic layout code, focusing on safer anchor processing and minor code style updates. The main changes ensure that the code correctly handles the case where a base glyph does not provide an anchor for a mark class, in line with the OpenType specification.
Robust handling of null anchors
ApplyAnchorinAdvancedTypographicUtils.csto accept a nullableAnchorTableand to safely return early if the anchor is null, preventing errors when a base glyph lacks an anchor for a mark class. This matches OpenType's allowance for null anchor offsets.Code style and clarity improvements
LookupType4Format1SubTable.Loadto use explicit types and object initializers for improved readability and consistency.TryUpdatePositionto use a more readable and idiomatic comparison (data.LigatureComponent <= 0instead of negating a greater-than check).