👋 I've been playing around with changing the entire font of a diagram to something fixed-width, starting by hand-editing `main.go` I noticed that if I switched over the family to Source Code Pro, d2 crashed with the following stack: ``` [23:38:30] info: compiling GetUniqueColumnName-fix.d2... panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x1c4 pc=0x16b562c] goroutine 43 [running]: github.com/golang/freetype/truetype.(*Font).Bounds(0xc000669670?, 0x0?) /Users/kevin/dev/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/truetype.go:378 +0xc github.com/golang/freetype/truetype.NewFace(0x0, 0xc0003276c0) /Users/kevin/dev/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/face.go:199 +0x325 oss.terrastruct.com/d2/lib/textmeasure.(*Ruler).addFontSize(0xc00037c000, {{0x1bb9a34, 0xd}, {0x1b82732, 0x4}, 0x1f}) /Users/kevin/dev/d2/lib/textmeasure/textmeasure.go:141 +0x112 oss.terrastruct.com/d2/lib/textmeasure.(*Ruler).MeasurePrecise(0xc00037c000, {{0x1bb9a34, 0xd}, {0x1b82732, 0x4}, 0x1f}, {0xc000582100, 0x1f}) /Users/kevin/dev/d2/lib/textmeasure/textmeasure.go:157 +0xde oss.terrastruct.com/d2/lib/textmeasure.(*Ruler).Measure(...) /Users/kevin/dev/d2/lib/textmeasure/textmeasure.go:151 oss.terrastruct.com/d2/d2graph.GetTextDimensions({0x0, 0x0, 0xc000657860?}, 0xc00037c000, 0xc000620280, 0xc000092020) ``` Which I tracked down to these missing styles, which appear to matter even if they aren't used. I acquired the `ttf` files from https://fonts.google.com/specimen/Source+Code+Pro I created the encoded fonts on my Mac with: ``` base64 -i SourceCodePro-Italic.ttf -o ../encoded/SourceCodePro-Italic.txt ``` Hopefully this is correct! Open to all feedback, especially since I think this is the first change I've ever made to a go program :) Signed-off-by: Kevin David <kevin-david@github.com>
117 KiB
117 KiB