From 07faf97941ea41210500476e76f220a8e1f01cc0 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 10 Apr 2023 14:38:34 -0700 Subject: [PATCH] using semibold --- d2renderers/d2fonts/d2fonts.go | 15 +++++++++++++++ d2renderers/d2svg/d2svg.go | 20 +++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/d2renderers/d2fonts/d2fonts.go b/d2renderers/d2fonts/d2fonts.go index 2e8532622..eed398ae7 100644 --- a/d2renderers/d2fonts/d2fonts.go +++ b/d2renderers/d2fonts/d2fonts.go @@ -115,6 +115,9 @@ var sourceCodeProRegularBase64 string //go:embed encoded/SourceCodePro-Bold.txt var sourceCodeProBoldBase64 string +//go:embed encoded/SourceCodePro-Semibold.txt +var sourceCodeProSemiboldBase64 string + //go:embed encoded/SourceCodePro-Italic.txt var sourceCodeProItalicBase64 string @@ -156,6 +159,10 @@ func init() { Family: SourceCodePro, Style: FONT_STYLE_BOLD, }: sourceCodeProBoldBase64, + { + Family: SourceCodePro, + Style: FONT_STYLE_SEMIBOLD, + }: sourceCodeProSemiboldBase64, { Family: SourceCodePro, Style: FONT_STYLE_ITALIC, @@ -204,6 +211,14 @@ func init() { Family: SourceCodePro, Style: FONT_STYLE_BOLD, }] = b + b, err = fontFacesFS.ReadFile("ttf/SourceCodePro-Semibold.ttf") + if err != nil { + panic(err) + } + FontFaces[Font{ + Family: SourceCodePro, + Style: FONT_STYLE_SEMIBOLD, + }] = b b, err = fontFacesFS.ReadFile("ttf/SourceCodePro-Italic.ttf") if err != nil { panic(err) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 9434f2d33..04d3a3c15 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -1434,21 +1434,19 @@ func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fon ), ) - if fontFamily != nil && *fontFamily == d2fonts.SourceSansPro { - appendOnTrigger( - buf, - source, - []string{`class="md"`}, - fmt.Sprintf(` + 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), - ), - ) - } + diagramHash, + fontFamily.Font(0, d2fonts.FONT_STYLE_SEMIBOLD).GetEncodedSubset(corpus), + ), + ) appendOnTrigger( buf,