From 423c7e88ebae0ccba1f1d407052b0f944f4aa088 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 10 Apr 2023 13:55:52 -0700 Subject: [PATCH] use semibold font instead of font-weight: 600 --- d2renderers/d2svg/d2svg.go | 17 +++++++++++++++++ d2renderers/d2svg/github-markdown.css | 16 +++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 8905d4077..9434f2d33 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -1434,6 +1434,22 @@ func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fon ), ) + if fontFamily != nil && *fontFamily == d2fonts.SourceSansPro { + appendOnTrigger( + buf, + source, + []string{`class="md"`}, + fmt.Sprintf(` +@font-face { + font-family: %s-font-semibold; + src: url("%s"); +}`, + diagramHash, + fontFamily.Font(0, d2fonts.FONT_STYLE_SEMIBOLD).GetEncodedSubset(corpus), + ), + ) + } + appendOnTrigger( buf, source, @@ -1769,6 +1785,7 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) { css = strings.ReplaceAll(css, "font-bold", fmt.Sprintf("%s-font-bold", diagramHash)) css = strings.ReplaceAll(css, "font-mono", fmt.Sprintf("%s-font-mono", diagramHash)) css = strings.ReplaceAll(css, "font-regular", fmt.Sprintf("%s-font-regular", diagramHash)) + css = strings.ReplaceAll(css, "font-semibold", fmt.Sprintf("%s-font-semibold", diagramHash)) fmt.Fprintf(upperBuf, ``, css) } diff --git a/d2renderers/d2svg/github-markdown.css b/d2renderers/d2svg/github-markdown.css index a797c6875..c271b67d7 100644 --- a/d2renderers/d2svg/github-markdown.css +++ b/d2renderers/d2svg/github-markdown.css @@ -70,7 +70,6 @@ .md h1 { margin: 0.67em 0; - font-weight: 600; padding-bottom: 0.3em; font-size: 2em; border-bottom: 1px solid var(--color-border-muted); @@ -240,35 +239,30 @@ .md h6 { margin-top: 24px; margin-bottom: 16px; - font-weight: 600; + font-weight: 400; line-height: 1.25; - font-family: "font-regular"; + font-family: "font-semibold"; } .md h2 { - font-weight: 600; padding-bottom: 0.3em; font-size: 1.5em; border-bottom: 1px solid var(--color-border-muted); } .md h3 { - font-weight: 600; font-size: 1.25em; } .md h4 { - font-weight: 600; font-size: 1em; } .md h5 { - font-weight: 600; font-size: 0.875em; } .md h6 { - font-weight: 600; font-size: 0.85em; color: var(--color-fg-muted); } @@ -465,7 +459,7 @@ margin-top: 16px; font-size: 1em; font-style: italic; - font-weight: 600; + font-family: "font-semibold"; } .md dl dd { @@ -474,7 +468,7 @@ } .md table th { - font-weight: 600; + font-family: "font-semibold"; } .md table th, @@ -677,7 +671,7 @@ } .md .csv-data th { - font-weight: 600; + font-family: "font-semibold"; background: var(--color-canvas-subtle); border-top: 0; }