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 #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

  • Updated ApplyAnchor in AdvancedTypographicUtils.cs to accept a nullable AnchorTable and 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

  • Refactored variable declarations in LookupType4Format1SubTable.Load to use explicit types and object initializers for improved readability and consistency.
  • Simplified the ligature component check in TryUpdatePosition to use a more readable and idiomatic comparison (data.LigatureComponent <= 0 instead of negating a greater-than check).

@JimBobSquarePants JimBobSquarePants merged commit 9f4b642 into main Nov 26, 2025
30 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-479 branch November 26, 2025 08:15
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 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 AnchorTable parameter nullable in ApplyAnchor with 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Another NullReferenceException when drawing text

2 participants