update label dimensions alonside font size
This commit is contained in:
parent
12e28f5195
commit
8a0204fa54
1 changed files with 7 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ func withoutGridDiagrams(ctx context.Context, g *d2graph.Graph, layout d2graph.L
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if len(child.ChildrenArray) > 0 {
|
} else if len(child.ChildrenArray) > 0 {
|
||||||
|
originalFontSize := child.Text().FontSize
|
||||||
tempGraph := g.ExtractAsNestedGraph(child)
|
tempGraph := g.ExtractAsNestedGraph(child)
|
||||||
// emulating setting font size with layout
|
// emulating setting font size with layout
|
||||||
fontSize := child.Text().FontSize
|
fontSize := child.Text().FontSize
|
||||||
|
|
@ -72,6 +73,12 @@ func withoutGridDiagrams(ctx context.Context, g *d2graph.Graph, layout d2graph.L
|
||||||
child.Style.FontSize = &d2graph.Scalar{}
|
child.Style.FontSize = &d2graph.Scalar{}
|
||||||
}
|
}
|
||||||
child.Style.FontSize.Value = strconv.Itoa(fontSize)
|
child.Style.FontSize.Value = strconv.Itoa(fontSize)
|
||||||
|
|
||||||
|
// update label dimensions
|
||||||
|
ratio := float64(fontSize) / float64(originalFontSize)
|
||||||
|
child.LabelDimensions.Height = int(math.Ceil(float64(child.LabelDimensions.Height) * ratio))
|
||||||
|
child.LabelDimensions.Width = int(math.Ceil(float64(child.LabelDimensions.Width) * ratio))
|
||||||
|
|
||||||
if err := layout(ctx, tempGraph); err != nil {
|
if err := layout(ctx, tempGraph); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue