From 3cd23a8fa4fef1f2269b78abc5ce43f67b367e17 Mon Sep 17 00:00:00 2001 From: Benoit KUGLER Date: Tue, 28 Nov 2023 14:58:27 +0100 Subject: [PATCH] [opentype/gpos] use plain struct instead of pointer --- harfbuzz/ot_layout_gpos.go | 4 ++-- opentype/tables/ot_properties.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/harfbuzz/ot_layout_gpos.go b/harfbuzz/ot_layout_gpos.go index eafa9c76..4b0854b4 100644 --- a/harfbuzz/ot_layout_gpos.go +++ b/harfbuzz/ot_layout_gpos.go @@ -285,8 +285,8 @@ func (c *otApplyContext) applyGPOSPair1(inner tables.PairPosData1, index int) bo skippyIter := &c.iterInput pos := skippyIter.idx set := inner.PairSets[index] - record := set.FindGlyph(gID(buffer.Info[skippyIter.idx].Glyph)) - if record == nil { + record, ok := set.FindGlyph(gID(buffer.Info[skippyIter.idx].Glyph)) + if !ok { buffer.unsafeToConcat(buffer.idx, pos+1) return false } diff --git a/opentype/tables/ot_properties.go b/opentype/tables/ot_properties.go index 54ae1042..64659b65 100644 --- a/opentype/tables/ot_properties.go +++ b/opentype/tables/ot_properties.go @@ -215,13 +215,13 @@ func (lk ExtensionPos) Cov() Coverage { return nil } // not used anyway // FindGlyph performs a binary search in the list, returning the record for `secondGlyph`, // or `nil` if not found. -func (ps PairSet) FindGlyph(secondGlyph GlyphID) *PairValueRecord { +func (ps PairSet) FindGlyph(secondGlyph GlyphID) (PairValueRecord, bool) { low, high := 0, int(ps.pairValueCount) for low < high { mid := low + (high-low)/2 // avoid overflow when computing mid rec, err := ps.data.get(mid) if err != nil { // argh... - return nil + return PairValueRecord{}, false } p := rec.SecondGlyph if secondGlyph < p { @@ -229,10 +229,10 @@ func (ps PairSet) FindGlyph(secondGlyph GlyphID) *PairValueRecord { } else if secondGlyph > p { low = mid + 1 } else { - return &rec + return rec, true } } - return nil + return PairValueRecord{}, false } // GetDelta returns the hint for the given `ppem`, scaled by `scale`.