diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7de8c32..0724ac4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,18 @@ jobs: - name: qpdf, the independent oracle for what we write run: sudo apt-get update -qq && sudo apt-get install -y -qq qpdf + # The check this lane never had. The tree was unformatted on main -- two + # files, under both 1.26's gofmt and 1.27's -- and nothing said so, because + # every sibling repository in the fleet checks gofmt and this one did not. + - name: Gofmt + run: | + out=$(gofmt -l .) + if [ -n "$out" ]; then + echo "gofmt needs to be run on:" + echo "$out" + exit 1 + fi + - name: go vet run: go vet ./... diff --git a/font_test.go b/font_test.go index bcc9be3..6305e33 100644 --- a/font_test.go +++ b/font_test.go @@ -88,11 +88,11 @@ func TestReadPSNameEdgeCases(t *testing.T) { w.u16(3) // count (claims 3 records) w.u16(uint16(6 + 3*12)) // storage offset // record 0: nameID 1 (skipped) - w.u16(3); w.u16(1); w.u16(0); w.u16(1); w.u16(4); w.u16(0) + w.u16s(3, 1, 0, 1, 4, 0) // record 1: nameID 6, platform 0 (Unicode UTF-16BE) "Uni" - w.u16(0); w.u16(3); w.u16(0); w.u16(6); w.u16(6); w.u16(0) + w.u16s(0, 3, 0, 6, 6, 0) // record 2: nameID 6 but offset/length out of range (skipped) - w.u16(1); w.u16(0); w.u16(0); w.u16(6); w.u16(0xffff); w.u16(0xffff) + w.u16s(1, 0, 0, 6, 0xffff, 0xffff) storage := []byte{0, 'U', 0, 'n', 0, 'i'} w.b = append(w.b, storage...) if s := readPSName(w.b); s != "Uni" { diff --git a/go.mod b/go.mod index 5008b66..0cb037f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-pdfkit/pdfkit -go 1.26.4 +go 1.27.1 require github.com/go-opentype/opentype v0.13.0 diff --git a/synth_test.go b/synth_test.go index d83fbc5..193bc8b 100644 --- a/synth_test.go +++ b/synth_test.go @@ -84,6 +84,15 @@ type bw struct{ b []byte } func (w *bw) u8(v uint8) { w.b = append(w.b, v) } func (w *bw) u16(v uint16) { w.b = binary.BigEndian.AppendUint16(w.b, v) } + +// u16s writes several big-endian uint16s, for a record whose fields read better on +// ONE line -- a name-table record is six numbers in a fixed order, and gofmt splits +// "w.u16(3); w.u16(1); …" into six lines, which hides that shape. +func (w *bw) u16s(vs ...uint16) { + for _, v := range vs { + w.u16(v) + } +} func (w *bw) u32(v uint32) { w.b = binary.BigEndian.AppendUint32(w.b, v) } func (w *bw) i16(v int16) { w.u16(uint16(v)) } diff --git a/units.go b/units.go index a774abe..d1b7d57 100644 --- a/units.go +++ b/units.go @@ -44,11 +44,11 @@ func (s PageSize) Portrait() PageSize { // Standard ISO 216 A-series and US page sizes, in points. var ( - A3 = PageSize{Width: Mm(297), Height: Mm(420)} - A4 = PageSize{Width: Mm(210), Height: Mm(297)} - A5 = PageSize{Width: Mm(148), Height: Mm(210)} - Letter = PageSize{Width: In(8.5), Height: In(11)} - Legal = PageSize{Width: In(8.5), Height: In(14)} + A3 = PageSize{Width: Mm(297), Height: Mm(420)} + A4 = PageSize{Width: Mm(210), Height: Mm(297)} + A5 = PageSize{Width: Mm(148), Height: Mm(210)} + Letter = PageSize{Width: In(8.5), Height: In(11)} + Legal = PageSize{Width: In(8.5), Height: In(14)} Tabloid = PageSize{Width: In(11), Height: In(17)} )