Skip to content

Commit

Permalink
[opentype/gpos] use plain struct instead of pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitkugler committed Nov 28, 2023
1 parent 3b7c920 commit 3cd23a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions harfbuzz/ot_layout_gpos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions opentype/tables/ot_properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,24 +215,24 @@ 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 {
high = mid
} 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`.
Expand Down

0 comments on commit 3cd23a8

Please sign in to comment.