gmlewis / go-gerber Goto Github PK
View Code? Open in Web Editor NEWWrite Gerber RS274X files (for PCBs) in Go
License: Apache License 2.0
Write Gerber RS274X files (for PCBs) in Go
License: Apache License 2.0
Nolans-Air:dual-bifilar-coil nolansingroy$ ls
README.md main.go
dual-bifilar-coil-diagram.png view.sh
dual-bifilar-coil-layers.gif
Nolans-Air:dual-bifilar-coil nolansingroy$ go run main.go
go: extracting github.com/gmlewis/go-fonts v0.0.6
-> unzip /Users/nolansingroy/go/pkg/mod/cache/download/github.com/gmlewis/go-fonts/@v/v0.0.6.zip: malformed file path "fonts/airstream/Nick's Fonts License.txt": invalid char '''
build command-line-arguments: cannot load github.com/gmlewis/go-fonts/fonts: unzip /Users/nolansingroy/go/pkg/mod/cache/download/github.com/gmlewis/go-fonts/@v/v0.0.6.zip: malformed file path "fonts/airstream/Nick's Fonts License.txt": invalid char '''
Nolans-Air:dual-bifilar-coil nolansingroy$
i should say that im new to go, but not to other languages.
I found this little gem of yours searching for gerber files of bifilar coils, installed go and tried to do one of the examples ..
i get some errors, i wonder is this a go or gcc version issue ?
C:\Users\Mårten Sundling>cd C:\Users\Mårten Sundling\Documents\go-gerber-master\examples\bifilar-with-capacitor
C:\Users\Mårten Sundling\Documents\go-gerber-master\examples\bifilar-with-capacitor>go run main.go
In file included from ........\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]\c_glfw.go:4:
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c: In function 'glfwSwapBuffers':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c:646:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c: In function 'glfwExtensionSupported':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c:680:1: error: converting to execution character set: Illegal byte sequence
assert(extension != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c: In function 'glfwGetProcAddress':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/context.c:746:1: error: converting to execution character set: Illegal byte sequence
assert(procname != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ........\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]\c_glfw.go:6:
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwGetInputMode':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:476:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetInputMode':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:501:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwGetKey':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:632:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwGetMouseButton':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:655:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwGetCursorPos':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:678:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetCursorPos':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:701:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwCreateCursor':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:734:1: error: converting to execution character set: Illegal byte sequence
assert(image != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetCursor':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:820:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetKeyCallback':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:832:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetCharCallback':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:842:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetCharModsCallback':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:852:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetMouseButtonCallback':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:863:1: error: converting to execution character set: Illegal byte sequence
assert(window != NULL);
^ ~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c: In function 'glfwSetCursorPosCallback':
C:\Users\M�rten Sundling\go\pkg\mod\github.com\go-gl\glfw\v3.3\[email protected]/glfw/src/input.c:874:1: error: converting to execution character set: Illegal byte sequence
Describe the bug
reproducible segfault in gerber.Gerber.WriteGerber
if empty text objects are included.
To Reproduce
The below code reproduces the issue. If text is supplied via the -text
flag, should have no segfault.
package main
import (
"flag"
"fmt"
"os"
"github.com/gmlewis/go-fonts/fonts"
_ "github.com/gmlewis/go-fonts/fonts/bitstreamverasansmono_bold"
"github.com/gmlewis/go-gerber/gerber"
)
func main() {
var text string
flag.StringVar(&text, "text", "", "text to render on the panel")
flag.Parse()
g := gerber.New("textbug")
g.TopSilkscreen().Add(
gerber.Text(
25, 25,
1.0, // for top silk
text,
"bitstreamverasansmono_bold",
12,
&gerber.TextOpts{XAlign: fonts.XCenter, YAlign: fonts.YCenter},
),
)
if err := g.WriteGerber(); err != nil {
fmt.Printf("write: %v", err)
os.Exit(1)
}
}
Expected behavior
gerber.Text
API does not return errors, so perhaps log a warning instead? Not really sure what's best here.
Screenshots
$ go build && rm -f textbug.* && ./gerber-empty-text-bug -text='' && gerbv textbug*
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x102be9270]
goroutine 1 [running]:
github.com/gmlewis/go-fonts/fonts.TextMBB(0x4039000000000000, 0x4039000000000000, 0x4010eeeeeeeeeeef, 0x4010eeeeeeeeeeef, {0x16d4139e9, 0x0}, {0x102bf9091?, 0x1029f54cc?})
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/fonts/text.go:196 +0x2a0
github.com/gmlewis/go-fonts/fonts.Text(0x4039000000000000, 0x4039000000000000, 0x4010eeeeeeeeeeef, 0x4010eeeeeeeeeeef, {0x16d4139e9, 0x0}, {0x102bf9091, 0x1a}, 0x14000126078)
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/fonts/text.go:221 +0x7c
github.com/gmlewis/go-gerber/gerber.(*TextT).renderText(0x140001009b0)
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/gerber/text.go:109 +0x64
github.com/gmlewis/go-gerber/gerber.(*TextT).WriteGerber(0x140001009b0, {0x102ccd5c8, 0x14000100a00}, 0x7?)
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/gerber/text.go:143 +0x2c
github.com/gmlewis/go-gerber/gerber.(*Layer).WriteGerber(0x140003685a0, {0x102ccd5c8, 0x14000100a00})
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/gerber/layers.go:56 +0x220
github.com/gmlewis/go-gerber/gerber.(*Gerber).WriteGerber(0x14000141f30)
/Users/jslee/go/pkg/mod/github.com/gmlewis/[email protected]/gerber/gerber.go:43 +0x1bc
main.main()
/Users/jslee/vc/jsleeio/experiments/gerber/gerber-empty-text-bug/main.go:28 +0x358
Additional context
Am using macOS and Go 1.19.4. Also reproduced on Linux.
Thanks for making this library; it solved a problem for me :-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.