using semibold

This commit is contained in:
Gavin Nishizawa 2023-04-10 14:38:34 -07:00
parent d4228a171e
commit 07faf97941
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD
2 changed files with 24 additions and 11 deletions

View file

@ -115,6 +115,9 @@ var sourceCodeProRegularBase64 string
//go:embed encoded/SourceCodePro-Bold.txt //go:embed encoded/SourceCodePro-Bold.txt
var sourceCodeProBoldBase64 string var sourceCodeProBoldBase64 string
//go:embed encoded/SourceCodePro-Semibold.txt
var sourceCodeProSemiboldBase64 string
//go:embed encoded/SourceCodePro-Italic.txt //go:embed encoded/SourceCodePro-Italic.txt
var sourceCodeProItalicBase64 string var sourceCodeProItalicBase64 string
@ -156,6 +159,10 @@ func init() {
Family: SourceCodePro, Family: SourceCodePro,
Style: FONT_STYLE_BOLD, Style: FONT_STYLE_BOLD,
}: sourceCodeProBoldBase64, }: sourceCodeProBoldBase64,
{
Family: SourceCodePro,
Style: FONT_STYLE_SEMIBOLD,
}: sourceCodeProSemiboldBase64,
{ {
Family: SourceCodePro, Family: SourceCodePro,
Style: FONT_STYLE_ITALIC, Style: FONT_STYLE_ITALIC,
@ -204,6 +211,14 @@ func init() {
Family: SourceCodePro, Family: SourceCodePro,
Style: FONT_STYLE_BOLD, Style: FONT_STYLE_BOLD,
}] = b }] = 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") b, err = fontFacesFS.ReadFile("ttf/SourceCodePro-Italic.ttf")
if err != nil { if err != nil {
panic(err) panic(err)

View file

@ -1434,21 +1434,19 @@ func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fon
), ),
) )
if fontFamily != nil && *fontFamily == d2fonts.SourceSansPro { appendOnTrigger(
appendOnTrigger( buf,
buf, source,
source, []string{`class="md"`},
[]string{`class="md"`}, fmt.Sprintf(`
fmt.Sprintf(`
@font-face { @font-face {
font-family: %s-font-semibold; font-family: %s-font-semibold;
src: url("%s"); src: url("%s");
}`, }`,
diagramHash, diagramHash,
fontFamily.Font(0, d2fonts.FONT_STYLE_SEMIBOLD).GetEncodedSubset(corpus), fontFamily.Font(0, d2fonts.FONT_STYLE_SEMIBOLD).GetEncodedSubset(corpus),
), ),
) )
}
appendOnTrigger( appendOnTrigger(
buf, buf,