make Latex use N1 (Text) color

This commit is contained in:
Vojtěch Fošnár 2023-01-07 11:27:00 +01:00
parent 8f903d72e1
commit 0919cc160e
No known key found for this signature in database
GPG key ID: 657727E71C40859A

View file

@ -68,7 +68,7 @@ type RenderOpts struct {
ThemeID int64 ThemeID int64
} }
func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int, bgColor string) (width int, height int) { func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int, bgColor string, fgColor string) (width int, height int) {
tl, br := diagram.BoundingBox() tl, br := diagram.BoundingBox()
w := br.X - tl.X + pad*2 w := br.X - tl.X + pad*2
h := br.Y - tl.Y + pad*2 h := br.Y - tl.Y + pad*2
@ -78,9 +78,9 @@ func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int, bgColor st
fmt.Fprintf(writer, `<?xml version="1.0" encoding="utf-8"?> fmt.Fprintf(writer, `<?xml version="1.0" encoding="utf-8"?>
<svg <svg
id="d2-svg" id="d2-svg"
style="background: %s;" style="background: %s; color: %s;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
width="%d" height="%d" viewBox="%d %d %d %d">`, bgColor, w, h, tl.X-pad, tl.Y-pad, w, h) width="%d" height="%d" viewBox="%d %d %d %d">`, bgColor, fgColor, w, h, tl.X-pad, tl.Y-pad, w, h)
return w, h return w, h
} }
@ -1125,7 +1125,7 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
fgColor := theme.Colors.Neutrals.N1 fgColor := theme.Colors.Neutrals.N1
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
w, h := setViewbox(buf, diagram, pad, bgColor) w, h := setViewbox(buf, diagram, pad, bgColor, fgColor)
styleCSS2 := "" styleCSS2 := ""
if sketchRunner != nil { if sketchRunner != nil {