Skip to content

Commit

Permalink
Merge pull request #1108 from gavin-ts/bold-edge-label
Browse files Browse the repository at this point in the history
fix: bold edge label padding
  • Loading branch information
gavin-ts authored Mar 30, 2023
2 parents 3dfafca + 505207a commit d46c3ed
Show file tree
Hide file tree
Showing 7 changed files with 744 additions and 1 deletion.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
#### Bugfixes ⛑️

- prevent an object's `near` from targeting a text near a constant. [#1100](https://github.com/terrastruct/d2/pull/1100)
- fixes inaccurate bold edge label padding. [#1108](https://github.com/terrastruct/d2/pull/1108)
6 changes: 5 additions & 1 deletion d2graph/d2graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,14 @@ func (e *Edge) Text() *d2target.MText {
if e.Attributes.Style.FontSize != nil {
fontSize, _ = strconv.Atoi(e.Attributes.Style.FontSize.Value)
}
isBold := false
if e.Attributes.Style.Bold != nil {
isBold, _ = strconv.ParseBool(e.Attributes.Style.Bold.Value)
}
return &d2target.MText{
Text: e.Attributes.Label.Value,
FontSize: fontSize,
IsBold: false,
IsBold: isBold,
IsItalic: true,

Dimensions: e.LabelDimensions,
Expand Down
10 changes: 10 additions & 0 deletions e2etests/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,16 @@ l3c2.c -> l4.c3.c`,
name: "link_with_ampersand",
script: `a.link: https://calendar.google.com/calendar/u/0/r?tab=mc&pli=1`,
},
{
name: "bold_edge_label",
script: `
direction: right
x -> y: sync
y -> z: sync {
style.bold: true
}
`,
},
}

runa(t, tcs)
Expand Down
270 changes: 270 additions & 0 deletions e2etests/testdata/regression/bold_edge_label/dagre/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d46c3ed

Please sign in to comment.