You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See below fix. x (GlyphIndex) is uint16, and x * 4 can easily get overflowed, this will end up returning incorrect advance or bounding box for a glyph.
diff --git a/font/sfnt/sfnt.go b/font/sfnt/sfnt.go
index b6045e7..fc782d8 100644
--- a/font/sfnt/sfnt.go
+++ b/font/sfnt/sfnt.go
@@ -1522,7 +1522,7 @@ func (f *Font) GlyphBounds(b *Buffer, x GlyphIndex, ppem fixed.Int26_6, h font.H
x = n
}
- buf, err := b.view(&f.src, int(f.hmtx.offset)+int(4*x), 2)
+ buf, err := b.view(&f.src, int(f.hmtx.offset)+int(x)*4, 2)
if err != nil {
return fixed.Rectangle26_6{}, 0, err
}
@@ -1602,7 +1602,7 @@ func (f *Font) GlyphAdvance(b *Buffer, x GlyphIndex, ppem fixed.Int26_6, h font.
x = n
}
- buf, err := b.view(&f.src, int(f.hmtx.offset)+int(4*x), 2)
+ buf, err := b.view(&f.src, int(f.hmtx.offset)+int(x)*4, 2)
if err != nil {
return 0, err
}
What version of Go are you using (go version)?
$ go version
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
What did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered:
See below fix. x (GlyphIndex) is uint16, and x * 4 can easily get overflowed, this will end up returning incorrect advance or bounding box for a glyph.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: