From f39a23b8dc9137458a6e4591a9f575ecf4e04a24 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 10 Nov 2020 23:39:48 +0100 Subject: [PATCH] switch to own SVG of the Swiss cross Compared to the Adobe Illustrator-exported version from SIX, this version is defined on a 166px x 166px viewbox, which are the recommended dimensions with which the cross should be overlaid on top of QR codes. This versions visually matches the PNG version from SIX when rendered onto the same pixel size (166px x 166px). But, this version scales better! The SIX version does not render correctly. My guess is that it might have to do with their use of floating point coordinates. --- GENERATED_swisscross.go | 2 ++ generate.go | 2 +- qrbill.go | 4 ++-- swisscross.svg | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 swisscross.svg diff --git a/GENERATED_swisscross.go b/GENERATED_swisscross.go index adeab15..365dac1 100644 --- a/GENERATED_swisscross.go +++ b/GENERATED_swisscross.go @@ -4,6 +4,8 @@ package qrbill var swisscross = map[string][]byte{ "third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.png": swisscross_0, "third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.svg": swisscross_1, + "swisscross.svg": swisscross_2, } var swisscross_0 = []byte("\x89PNG \n\n\x00\x00\x00 IHDR\x00\x00\x00\xa6\x00\x00\x00\xa6\x00\x00\x00\x00x\xf3\xc9\xda\x00\x00\x00 pHYs\x00\x00\\F\x00\x00\\F\x94CA\x00\x0080iTXtXML:com.adobe.xmp\x00\x00\x00\x00\x00\n\n \n \n Adobe Photoshop CC 2015.5 (Macintosh)\n 2017-06-07T09:36:22+02:00\n 2017-06-07T09:43:10+02:00\n 2017-06-07T09:43:10+02:00\n image/png\n 0\n xmp.iid:d37a2394-3f20-4130-9fc2-6cccaed7bb7f\n xmp.did:d37a2394-3f20-4130-9fc2-6cccaed7bb7f\n xmp.did:d37a2394-3f20-4130-9fc2-6cccaed7bb7f\n \n \n \n created\n xmp.iid:d37a2394-3f20-4130-9fc2-6cccaed7bb7f\n 2017-06-07T09:36:22+02:00\n Adobe Photoshop CC 2015.5 (Macintosh)\n \n \n \n 1\n 6000000/10000\n 6000000/10000\n 2\n 65535\n 166\n 166\n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\x98\xfd\xb9B\x00\x00\x00 cHRM\x00\x00\x87\n\x00\x00\x8c \x00\xb7\x00\x00\x80\xe8\x00\x00R\x00[\x00\x006\xaf\x00\x00A\xd0\xdci\x00\x00\x00\xb9IDATx\xda\xec\x97K\xc20 Dm\x87}\x8f\x94\xabs\xa4r\x80tX\xf0i\xde \x83Y\xa0d=Yv2\x9e\xb8\xaaÒ\xdcR\xea)E\xebD5\"6\xa7\x83\xa9fX\xdf`Q-W'\x88X\xfa2yM\xa6!\xeb\xe0D/\xd2wϻ\x008\xe2_\xc6})mD5\xc6}\x90\xdff\xfb\xa9SM\xf6/s +Rry\x9b\xdc\xe3\x9b: \x80\xd5\xcc\xfa\xddÍ8\x99>K\x82\xb8\xc5V\xd4!\xdd;U\xd3ȋ\xce0\x88^|az>\xbf\x85\x879\xd9!\xabE\x9d\x9ftҗuzl.>ՙ\xb4\x8c\xca(B\xaf\x00\x89\xabA\x00\x80\x85S\x00\x00\x00\x00IEND\xaeB`\x82") var swisscross_1 = []byte("\n\n\n\n\n\n\n\n\n") +var swisscross_2 = []byte("\n\n \n \n \n \n\n") diff --git a/generate.go b/generate.go index 050155c..db9009d 100644 --- a/generate.go +++ b/generate.go @@ -14,4 +14,4 @@ package qrbill -//go:generate sh -c "go run third_party/goembed/goembed.go -package qrbill -var swisscross third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.png third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.svg > GENERATED_swisscross.go && gofmt -w GENERATED_swisscross.go" +//go:generate sh -c "go run third_party/goembed/goembed.go -package qrbill -var swisscross third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.png third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.svg swisscross.svg > GENERATED_swisscross.go && gofmt -w GENERATED_swisscross.go" diff --git a/qrbill.go b/qrbill.go index c062d2a..c39e4c7 100644 --- a/qrbill.go +++ b/qrbill.go @@ -277,11 +277,11 @@ func (b *Bill) EncodeToSVG() ([]byte, error) { } // overlay the swiss cross - cross := swisscross["third_party/swiss-cross/CH-Kreuz_7mm/CH-Kreuz_7mm.svg"] + cross := swisscross["swisscross.svg"] // Remove XML document header, we embed the element: cross = bytes.ReplaceAll(cross, []byte(``), nil) // Overwrite position and size of the embedded element: - cross = bytes.ReplaceAll(cross, []byte(`x="0px" y="0px"`), []byte(`x="549" y="549" width="166" height="166"`)) + cross = bytes.ReplaceAll(cross, []byte(` document: return bytes.ReplaceAll(qrCodeSVG, []byte(``), append(cross, []byte("")...)), nil diff --git a/swisscross.svg b/swisscross.svg new file mode 100644 index 0000000..68f4693 --- /dev/null +++ b/swisscross.svg @@ -0,0 +1,7 @@ + + + + + + +