From 93fcf28c6a6c25067dbeed0b6b09bb755393ff1d Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sun, 30 Aug 2026 12:30:33 +0000 Subject: [PATCH 1/2] fix(deps): update dependencies --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 2464cd2..cafe306 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.26.4 require github.com/go-opentype/opentype v0.6.0 require ( - github.com/go-widgets/painter v0.11.0 - github.com/go-widgets/toolkit v0.288.0 + github.com/go-widgets/painter v0.12.0 + github.com/go-widgets/toolkit v0.286.0 rsc.io/pdf v0.1.1 ) diff --git a/go.sum b/go.sum index 63a93a2..e294d22 100644 --- a/go.sum +++ b/go.sum @@ -30,10 +30,10 @@ github.com/go-typeset/bidi v0.3.0 h1:4fjGjejvjE2LzLNzY4si8PkVO321NcsKIiANhWT3jF4 github.com/go-typeset/bidi v0.3.0/go.mod h1:ct3cmYT8Qt1FGJQ+2QaakrUxqaP4ZysgdQQg2ym5+Xo= github.com/go-widgets/mvvm v0.5.0 h1:o5hh6HAxbApONcbZxmyV9q12pCAPGRd6L24aS3gaCbA= github.com/go-widgets/mvvm v0.5.0/go.mod h1:Phdrd434RLxXW1D6dL1PPQH1tABwYLIN2X7jQVC4TbY= -github.com/go-widgets/painter v0.11.0 h1:xsj4zTz8B43rOZnWrx7ZsaUBMgJyvgaE/Pq2FfcG2Sw= -github.com/go-widgets/painter v0.11.0/go.mod h1:IPRLqdUJuJX8sfuHeYLZCzjoLvA0ApbOlyIAVmguJDQ= -github.com/go-widgets/toolkit v0.288.0 h1:vtQDXZAbZRSQqIoEYQf/xE8ARE4YV4QtfHGHgnKP6NM= -github.com/go-widgets/toolkit v0.288.0/go.mod h1:IaRQFcV6FjxwzGXpHd3dpEoWZ+82f7dMPwtEZSH4nIg= +github.com/go-widgets/painter v0.12.0 h1:gMqTVbIbGSKmaE28NKsbbKdNIk2drupNMNuLjFP6T6I= +github.com/go-widgets/painter v0.12.0/go.mod h1:IPRLqdUJuJX8sfuHeYLZCzjoLvA0ApbOlyIAVmguJDQ= +github.com/go-widgets/toolkit v0.286.0 h1:ERZr3PS4zAraJBpzZE8/ewxpXb+TlxsI2VRMlTOV1EI= +github.com/go-widgets/toolkit v0.286.0/go.mod h1:IaRQFcV6FjxwzGXpHd3dpEoWZ+82f7dMPwtEZSH4nIg= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= From 2cfb0a339da213309533c97ea616952d68f8e765 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sun, 30 Aug 2026 17:39:44 +0200 Subject: [PATCH 2/2] font: make the cmap requirement pdfkit's own The dependency bump this branch carries takes go-opentype from v0.6.0 to v0.12.0, where a missing 'cmap' table stopped being a parse error. The test had leaned on that strictness -- its comment said so, "opentype (which requires a cmap) rejects it" -- so the bump turned a passing assertion into a failing one. Borrowing the check was the mistake, not the upgrade. pdfkit resolves every rune through Font.GlyphIndex, so a font with no cmap maps nothing and would draw a page of blanks with no error anywhere. The requirement belongs to pdfkit and is now stated in LoadFont, which no longer depends on how strict the parser happens to be this release. Co-Authored-By: Claude Opus 5 --- font.go | 9 +++++++++ font_test.go | 5 +++-- go.mod | 4 ++-- go.sum | 8 ++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/font.go b/font.go index 7d4d880..6b8d940 100644 --- a/font.go +++ b/font.go @@ -34,6 +34,15 @@ func LoadFont(data []byte) (*Font, error) { // The face is sized to the em, so AdvanceIndexUnits returns advances in font // units — exactly what a PDF /W width array wants — at the base (uninstanced) // design. + // opentype accepts a font with no character map; pdfkit cannot. Every text + // call resolves runes through Font.GlyphIndex, so a font without a 'cmap' + // maps nothing and would silently draw a page of blanks. The requirement is + // pdfkit's own and is stated here, rather than borrowed from however strict + // the parser happens to be. + if _, ok := ot.Table("cmap"); !ok { + return nil, fmt.Errorf("pdfkit: parse font: no cmap table, the font maps no characters") + } + face := ot.NewFace(ot.UnitsPerEm()) name := "" diff --git a/font_test.go b/font_test.go index a4fefa3..bcc9be3 100644 --- a/font_test.go +++ b/font_test.go @@ -10,8 +10,9 @@ func TestLoadFontErrors(t *testing.T) { if _, err := LoadFont([]byte("not a font")); err == nil { t.Error("expected opentype parse error") } - // A valid sfnt container missing cmap: opentype (which requires a cmap) - // rejects it, covering LoadFont's error branch. + // A valid sfnt container missing cmap. opentype used to reject this and the + // test leaned on that; since it became optional upstream, LoadFont makes the + // check itself, because pdfkit resolves every rune through the cmap. if _, err := LoadFont(synthTTF(synthOpts{noCmap: true})); err == nil { t.Error("expected opentype parse error for missing cmap") } diff --git a/go.mod b/go.mod index cafe306..0cdd7d1 100644 --- a/go.mod +++ b/go.mod @@ -2,11 +2,11 @@ module github.com/go-pdfkit/pdfkit go 1.26.4 -require github.com/go-opentype/opentype v0.6.0 +require github.com/go-opentype/opentype v0.12.0 require ( github.com/go-widgets/painter v0.12.0 - github.com/go-widgets/toolkit v0.286.0 + github.com/go-widgets/toolkit v0.289.0 rsc.io/pdf v0.1.1 ) diff --git a/go.sum b/go.sum index e294d22..1ba8029 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-opentype/fonts v0.8.0 h1:77i3VPIH90GbstzNb21mk+an4WvEOe2idC6W+J0n0fw= github.com/go-opentype/fonts v0.8.0/go.mod h1:C6yQL2apHItfEZ5hztpsHF0S5mlX/hklLlq/Z5fRG/g= -github.com/go-opentype/opentype v0.6.0 h1:2t1Qs/Uo4M+f9gahV5QGihLTTeI/q4s0l7MIsbkd290= -github.com/go-opentype/opentype v0.6.0/go.mod h1:AOixevJf7XQaH7+WG+OMIOZEbYPXfMqklVk26Y6YTUU= +github.com/go-opentype/opentype v0.12.0 h1:wBlcDi+3ZaNZXEt5z+Ixr11/cYYwi5W+jX6yTl/qr1I= +github.com/go-opentype/opentype v0.12.0/go.mod h1:AOixevJf7XQaH7+WG+OMIOZEbYPXfMqklVk26Y6YTUU= github.com/go-opentype/shape v0.5.0 h1:jHNaOMHNBdDj5EixOevlrrsi92svMxvVMKN7GYaPfxo= github.com/go-opentype/shape v0.5.0/go.mod h1:3ImRYNIj6zpwWQ/DV3BWhgMFfmzDITH6XpZw2auQHTo= github.com/go-richdoc/richdoc v0.2.0 h1:z9cLox9MoInZL6fIlweMzgDT/VqgnB2ZucSIEaRFglY= @@ -32,8 +32,8 @@ github.com/go-widgets/mvvm v0.5.0 h1:o5hh6HAxbApONcbZxmyV9q12pCAPGRd6L24aS3gaCbA github.com/go-widgets/mvvm v0.5.0/go.mod h1:Phdrd434RLxXW1D6dL1PPQH1tABwYLIN2X7jQVC4TbY= github.com/go-widgets/painter v0.12.0 h1:gMqTVbIbGSKmaE28NKsbbKdNIk2drupNMNuLjFP6T6I= github.com/go-widgets/painter v0.12.0/go.mod h1:IPRLqdUJuJX8sfuHeYLZCzjoLvA0ApbOlyIAVmguJDQ= -github.com/go-widgets/toolkit v0.286.0 h1:ERZr3PS4zAraJBpzZE8/ewxpXb+TlxsI2VRMlTOV1EI= -github.com/go-widgets/toolkit v0.286.0/go.mod h1:IaRQFcV6FjxwzGXpHd3dpEoWZ+82f7dMPwtEZSH4nIg= +github.com/go-widgets/toolkit v0.289.0 h1:iVbye2D7YMAkUOcJOXYNZKXqyeOmnxtRhdzEBlbBcz8= +github.com/go-widgets/toolkit v0.289.0/go.mod h1:IaRQFcV6FjxwzGXpHd3dpEoWZ+82f7dMPwtEZSH4nIg= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=