Commit graph

15 commits

Author SHA1 Message Date
Bernard Xie
e5eeebefde
remove custom font cli 2023-03-28 11:30:03 -07:00
Bernard Xie
ffc414260e
refactor 2023-03-27 19:26:49 -07:00
Bernard Xie
48a7472667
add and fix utf8cutfont 2023-03-27 19:19:12 -07:00
Bernard Xie
f195053ef3
small change 2023-03-27 15:38:53 -07:00
Bernard Xie
ff1ef999a3
tests still borken 2023-03-27 14:46:03 -07:00
Bernard Xie
7a137227e7
test without woff 2023-03-27 14:17:48 -07:00
Bernard Xie
2d6243ded3
cutset test 2023-03-27 13:41:40 -07:00
Bernard Xie
7c146dd213
subset fonts 2023-03-24 19:50:16 -07:00
Bernard Xie
194fb58027
Update d2renderers/d2fonts/d2fonts.go
Co-authored-by: gavin-ts <85081687+gavin-ts@users.noreply.github.com>
2023-03-24 17:31:58 -07:00
Bernard Xie
54b501dc92
errors that make more sense 2023-03-24 15:36:51 -07:00
Bernard Xie
811a630fb7
Add cli option 2023-03-24 15:04:35 -07:00
Alexander Wang
ba282b5f96
font: mono 2023-03-09 20:06:15 -08:00
Kevin David
bd7e18395e
d2renderers: d2fonts: add bold + italic styles for Source Code Pro
👋 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>
2023-01-23 00:35:19 -05:00
Alexander Wang
07fb1a3d86
implement sketch 2022-12-21 20:55:27 -08:00
Alexander Wang
524c089a74 oss
Co-authored-by: Anmol Sethi <hi@nhooyr.io>
2022-11-03 06:54:49 -07:00