Skip to content

Commit

Permalink
[opentype] add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitkugler committed Oct 13, 2023
1 parent 87ab5ec commit fba8cc7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Binary file added opentype/api/font/test/Selawik-VF-Subset.ttf
Binary file not shown.
27 changes: 27 additions & 0 deletions opentype/api/font/variations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package font

import (
"os"
"reflect"
"testing"

Expand Down Expand Up @@ -122,3 +123,29 @@ func TestAdvanceNoHVar(t *testing.T) {
tu.Assert(t, exp == got)
}
}

func TestInvalidGVAR(t *testing.T) {
f, err := os.Open("test/Selawik-VF-Subset.ttf")
tu.AssertNoErr(t, err)
defer f.Close()

ld, err := loader.NewLoader(f)
tu.AssertNoErr(t, err)

head, _, _ := LoadHeadTable(ld, nil)
raw, _ := ld.RawTable(loader.MustNewTag("maxp"))
maxp, _, _ := tables.ParseMaxp(raw)
raw, _ = ld.RawTable(loader.MustNewTag("glyf"))
locaRaw, _ := ld.RawTable(loader.MustNewTag("loca"))
loca, _ := tables.ParseLoca(locaRaw, int(maxp.NumGlyphs), head.IndexToLocFormat == 1)
glyf, _ := tables.ParseGlyf(raw, loca)

raw, err = ld.RawTable(loader.MustNewTag("gvar"))
tu.AssertNoErr(t, err)
gvar, _, err := tables.ParseGvar(raw)
tu.AssertNoErr(t, err)
// check that newGvar does not crash..
_, err = newGvar(gvar, glyf)
// ... and report and error
tu.Assert(t, err != nil)
}

0 comments on commit fba8cc7

Please sign in to comment.