Skip to content

Commit 9f4b642

Browse files
Merge pull request #482 from SixLabors/js/fix-479
Allow null AnchorTable
2 parents c2dddae + fc9d0c7 commit 9f4b642

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/SixLabors.Fonts/Tables/AdvancedTypographic/AdvancedTypographicUtils.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,19 @@ public static void ApplyAnchor(
249249
FontMetrics fontMetrics,
250250
GlyphPositioningCollection collection,
251251
int index,
252-
AnchorTable baseAnchor,
252+
AnchorTable? baseAnchor,
253253
MarkRecord markRecord,
254254
int baseGlyphIndex,
255255
Tag feature)
256256
{
257+
// baseAnchor may be null because OpenType MarkToBase allows NULL anchor offsets
258+
// in BaseArray/BaseRecord. A NULL offset means "this base glyph has no anchor
259+
// for this mark class", and the lookup must be ignored for this mark–base pair.
260+
if (baseAnchor is null)
261+
{
262+
return;
263+
}
264+
257265
GlyphShapingData baseData = collection[baseGlyphIndex];
258266
AnchorXY baseXY = baseAnchor.GetAnchor(fontMetrics, baseData, collection);
259267

src/SixLabors.Fonts/Tables/AdvancedTypographic/GPos/LookupType4SubTable.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public static LookupType4Format1SubTable Load(BigEndianBinaryReader reader, long
7171
ushort markArrayOffset = reader.ReadOffset16();
7272
ushort baseArrayOffset = reader.ReadOffset16();
7373

74-
var markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset);
75-
var baseCoverage = CoverageTable.Load(reader, offset + baseCoverageOffset);
76-
var markArrayTable = new MarkArrayTable(reader, offset + markArrayOffset);
77-
var baseArrayTable = new BaseArrayTable(reader, offset + baseArrayOffset, markClassCount);
74+
CoverageTable markCoverage = CoverageTable.Load(reader, offset + markCoverageOffset);
75+
CoverageTable baseCoverage = CoverageTable.Load(reader, offset + baseCoverageOffset);
76+
MarkArrayTable markArrayTable = new(reader, offset + markArrayOffset);
77+
BaseArrayTable baseArrayTable = new(reader, offset + baseArrayOffset, markClassCount);
7878

7979
return new LookupType4Format1SubTable(markCoverage, baseCoverage, markArrayTable, baseArrayTable, lookupFlags);
8080
}
@@ -106,7 +106,7 @@ public override bool TryUpdatePosition(
106106
while (--baseGlyphIndex >= 0)
107107
{
108108
GlyphShapingData data = collection[baseGlyphIndex];
109-
if (!AdvancedTypographicUtils.IsMarkGlyph(fontMetrics, data.GlyphId, data) && !(data.LigatureComponent > 0))
109+
if (!AdvancedTypographicUtils.IsMarkGlyph(fontMetrics, data.GlyphId, data) && data.LigatureComponent <= 0)
110110
{
111111
break;
112112
}

0 commit comments

Comments
 (0)