Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...

Expand Down
6 changes: 3 additions & 3 deletions font_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 9 additions & 0 deletions synth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }

Expand Down
10 changes: 5 additions & 5 deletions units.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
)

Expand Down
Loading