Commit graph

22 commits

Author SHA1 Message Date
Gavin Nishizawa
fdbde73605
rename to Get and MustGet 2023-10-30 13:51:37 -07:00
Gavin Nishizawa
1cfa2b9f81
use new SyncMap with FontFaces/FontEncoding 2023-10-30 12:15:32 -07:00
Gavin Nishizawa
a67c186cae
d2fonts.FontFaces sync.Map 2023-10-24 16:40:56 -07:00
Alexander Wang
e1cb60c91e
fix mixed md 2023-08-08 11:51:16 -07:00
Gavin Nishizawa
14300dc9f8
update leading/trailing accounting 2023-06-19 17:09:36 -07:00
Gavin Nishizawa
14afd8c433
improve code measurement and rendering 2023-06-19 17:09:36 -07:00
Gavin Nishizawa
d02e1ebb52
update markdown text measurement and rendering to use font-size 2023-04-12 20:14:45 -07:00
Gavin Nishizawa
3c832d36f6
measure with semibold 2023-04-10 15:06:26 -07:00
Alexander Wang
95bc2e4fb5
fix multiple br 2023-03-18 14:45:58 -07:00
Alexander Wang
56a4ee5fff
markdown strikethrough 2023-03-18 14:00:52 -07:00
Gavin Nishizawa
8fe2eee56d
lint 2023-03-14 11:20:00 -07:00
Alexander Wang
156c974241
unicode tests 2023-02-14 11:41:21 -08:00
Alexander Wang
9cb7e7f396
scale multi-width unicode 2023-02-14 11:40:49 -08:00
Kevin David
9ba1d85d21
d2graph: check that font family is entirely loaded before using it
I tested this by removing the changes I added in `d2fonts`, which led to:
```
[21:23:54] info: compiling GetUniqueColumnName-fix.d2...
[21:23:54] err: failed to compile: ruler does not have entire font family SourceCodePro loaded, is a style missing?
```

The error was also rendered in the UI.
2023-01-24 21:25:01 -05: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
Gavin Nishizawa
1a07492517
update li measurement + h1 border-bottom 2023-01-15 23:31:06 -08:00
Alexander Wang
9812ea54fb
test 2022-12-22 00:46:46 -08:00
Alexander Wang
39cc074757
cleanup 2022-12-22 00:45:32 -08:00
Alexander Wang
4ccaf4a578
ok 2022-12-21 23:57:56 -08:00
Alexander Wang
3a9a784342
wip 2022-12-21 23:13:52 -08:00
Anmol Sethi
a05ba67a36
go2: rm -rf 2022-12-01 10:49:15 -08:00
Anmol Sethi
c4ef432daf
Move textmeasure into lib
It's not a d2renderer.
2022-12-01 06:51:17 -08:00