Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- Encode and escape clip-path identifiers consistently in definitions and
references. [#2906](https://github.com/d2lang/d2/pull/2906)
- Escape color attributes across shapes, connections, labels, and themes. [#2909](https://github.com/d2lang/d2/pull/2909)
- Render LaTeX labels with the shape's font color instead of its stroke color.

---

Expand Down
2 changes: 1 addition & 1 deletion d2renderers/d2scenebuild/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (b *builder) preflightAssets() error {
if targetShape.Opacity == 0 || targetShape.Label == "" || targetShape.Language != "latex" {
continue
}
if _, err := b.resolveLatexAsset(fmt.Sprintf("shape %q", targetShape.ID), targetShape.Label, targetShape.Stroke); err != nil {
if _, err := b.resolveLatexAsset(fmt.Sprintf("shape %q", targetShape.ID), targetShape.Label, targetShape.GetFontColor()); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion d2renderers/d2scenebuild/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ func (b *builder) buildShapeText(targetShape d2target.Shape) ([]*d2scene.Node, e
topLeft := latexShapeLabelTopLeft(targetShape)
node, err := b.buildLatexLabelNode(
fmt.Sprintf("shape %q", targetShape.ID), targetShape.ID+":label:0",
targetShape.Label, targetShape.Stroke, topLeft,
targetShape.Label, targetShape.GetFontColor(), topLeft,
)
if err != nil {
return nil, err
Expand Down
11 changes: 6 additions & 5 deletions d2renderers/d2scenebuild/latex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestBuildLatexShapeAndConnectionLabels(t *testing.T) {
LabelFill: "#ff0000", Underline: true, Bold: true,
}
shape.LabelPosition = "INSIDE_MIDDLE_CENTER"
shape.Stroke = "#000000"
shape.Color = "#000000"
connection := &diagram.Connections[0]
connection.Text = d2target.Text{
Label: formula, Language: "latex",
Expand Down Expand Up @@ -114,11 +114,11 @@ func TestBuildLatexResolvesCurrentColorWithoutOverridingExplicitColor(t *testing
if err != nil {
t.Fatal(err)
}
makeShape := func(id string, x int, stroke string) d2target.Shape {
makeShape := func(id string, x int, fontColor string) d2target.Shape {
return d2target.Shape{
ID: id, Type: d2target.ShapeText, Pos: d2target.Point{X: x}, Width: width, Height: height,
Opacity: 1, Fill: "none", Stroke: stroke,
Text: d2target.Text{Label: formula, Language: "latex", LabelWidth: width, LabelHeight: height},
Opacity: 1, Fill: "none",
Text: d2target.Text{Label: formula, Language: "latex", LabelWidth: width, LabelHeight: height, Color: fontColor},
LabelPosition: "INSIDE_MIDDLE_CENTER",
}
}
Expand Down Expand Up @@ -214,9 +214,10 @@ func TestBuildLatexLabelRendersPixels(t *testing.T) {
diagram.Shapes = []d2target.Shape{{
ID: "formula", Type: d2target.ShapeText,
Width: width, Height: height, Opacity: 1,
Fill: "none", Stroke: "#0055cc",
Fill: "none",
Text: d2target.Text{
Label: formula, Language: "latex", LabelWidth: width, LabelHeight: height,
Color: "#0055cc",
},
LabelPosition: "INSIDE_MIDDLE_CENTER",
}}
Expand Down
2 changes: 1 addition & 1 deletion d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
)
gEl.SetTranslate(labelTL.X, labelTL.Y)

gEl.Color = targetShape.Stroke
gEl.Color = targetShape.GetFontColor()
gEl.SetInnerSVG(svg.TrustedFragment(render))
fmt.Fprint(writer, gEl.Render())
} else if targetShape.Language == "markdown" {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.