diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 767ebf9ed..538deb296 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -7,6 +7,8 @@ - `d2 fmt` accepts multiple files to be formatted [#718](https://github.com/terrastruct/d2/issues/718) +- `font-size` works for `sql_table` and `class` shapes [#769](https://github.com/terrastruct/d2/issues/769) + - You can now use the reserved keywords `layers`/`scenarios`/`steps` to define diagrams with multiple levels of abstractions. [#714](https://github.com/terrastruct/d2/pull/714) Docs to come soon diff --git a/d2exporter/export.go b/d2exporter/export.go index 2a34ed64a..5a57f0881 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -135,8 +135,11 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { shape.Label = obj.Attributes.Label.Value case d2target.ShapeClass: shape.Class = *obj.Class + // The label is the header for classes and tables, which is set in client to be 4 px larger than the object's set font size + shape.FontSize -= 4 case d2target.ShapeSQLTable: shape.SQLTable = *obj.SQLTable + shape.FontSize -= 4 } shape.Label = text.Text shape.LabelWidth = text.Dimensions.Width diff --git a/e2etests/testdata/measured/empty-class/dagre/board.exp.json b/e2etests/testdata/measured/empty-class/dagre/board.exp.json index 43926e6d3..8306771ac 100644 --- a/e2etests/testdata/measured/empty-class/dagre/board.exp.json +++ b/e2etests/testdata/measured/empty-class/dagre/board.exp.json @@ -30,7 +30,7 @@ "methods": null, "columns": null, "label": "", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", diff --git a/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg b/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg index 6927edd4b..a18febc0f 100644 --- a/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg +++ b/e2etests/testdata/measured/empty-class/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="316" height="248" viewBox="-102 -102 316 248"> \ No newline at end of file diff --git a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json index 296451a21..f6fec0464 100644 --- a/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json +++ b/e2etests/testdata/measured/empty-sql_table/dagre/board.exp.json @@ -30,7 +30,7 @@ "methods": null, "columns": null, "label": "", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", diff --git a/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg b/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg index 53a789b51..4d951fc2d 100644 --- a/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg +++ b/e2etests/testdata/measured/empty-sql_table/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="254" height="216" viewBox="-102 -102 254 216"> \ No newline at end of file diff --git a/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json b/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json index ae5cad2dc..2f0ed2f93 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json +++ b/e2etests/testdata/regression/empty_class_height/dagre/board.exp.json @@ -41,7 +41,7 @@ "methods": null, "columns": null, "label": "class with rows", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", @@ -84,7 +84,7 @@ "methods": null, "columns": null, "label": "class without rows", - "fontSize": 20, + "fontSize": 16, "fontFamily": "DEFAULT", "language": "", "color": "#0A0F25", diff --git a/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg b/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg index e69b90472..e62d41570 100644 --- a/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/empty_class_height/dagre/sketch.exp.svg @@ -39,11 +39,11 @@ width="866" height="388" viewBox="-102 -102 866 388">containerscloudtall cylinderclass- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidusersid -int -name -string -email -string -password -string -last_login -datetime -container

markdown text expanded to 800x400

+containerscloudtall cylinderclass- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidusersid +int +name +string +email +string +password +string +last_login +datetime +container

markdown text expanded to 800x400

:= 5 := a + 7 fmt.Printf("%d", b):= 5 := a + 7 -fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval +fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval containerscloudtall cylinderclass- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidusersid -int -name -string -email -string -password -string -last_login -datetime -container

markdown text expanded to 800x400

+containerscloudtall cylinderclass- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidusersid +int +name +string +email +string +password +string +last_login +datetime +container

markdown text expanded to 800x400

:= 5 := a + 7 fmt.Printf("%d", b):= 5 := a + 7 -fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval +fmt.Printf("%d", b)circle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval