Merge pull request #741 from alixander/bold-tests

update code fonts
This commit is contained in:
Alexander Wang 2023-01-29 14:24:08 -08:00 committed by GitHub
commit 4b72b65380
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 224 additions and 57 deletions

View file

@ -8,6 +8,8 @@
#### Improvements 🧹 #### Improvements 🧹
- Code snippets use bold and italic font styles as determined by highlighter [#710](https://github.com/terrastruct/d2/issues/710), [#741](https://github.com/terrastruct/d2/issues/741)
#### Bugfixes ⛑️ #### Bugfixes ⛑️
- Fixes groups overlapping in sequence diagrams when they end in a self loop. [#728](https://github.com/terrastruct/d2/pull/728) - Fixes groups overlapping in sequence diagrams when they end in a self loop. [#728](https://github.com/terrastruct/d2/pull/728)

View file

@ -47,7 +47,8 @@ func styleAttr(styles map[chroma.TokenType]string, tt chroma.TokenType) string {
} }
} }
} }
return styles[tt] out := strings.Replace(styles[tt], `font-weight="bold"`, `class="text-mono-bold"`, -1)
return strings.Replace(out, `font-style="italic"`, `class="text-mono-italic"`, -1)
} }
// <<< END // <<< END

View file

@ -1181,6 +1181,44 @@ func embedFonts(buf *bytes.Buffer, fontFamily *d2fonts.FontFamily) {
} }
} }
triggers = []string{
`class="text-mono-bold"`,
}
for _, t := range triggers {
if strings.Contains(content, t) {
fmt.Fprintf(buf, `
.text-mono-bold {
font-family: "font-mono-bold";
}
@font-face {
font-family: font-mono-bold;
src: url("%s");
}`,
d2fonts.FontEncodings[d2fonts.SourceCodePro.Font(0, d2fonts.FONT_STYLE_BOLD)])
break
}
}
triggers = []string{
`class="text-mono-italic"`,
}
for _, t := range triggers {
if strings.Contains(content, t) {
fmt.Fprintf(buf, `
.text-mono-italic {
font-family: "font-mono-italic";
}
@font-face {
font-family: font-mono-italic;
src: url("%s");
}`,
d2fonts.FontEncodings[d2fonts.SourceCodePro.Font(0, d2fonts.FONT_STYLE_ITALIC)])
break
}
}
buf.WriteString(`]]></style>`) buf.WriteString(`]]></style>`)
} }

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 350 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 350 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 512 KiB

After

Width:  |  Height:  |  Size: 601 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 512 KiB

After

Width:  |  Height:  |  Size: 601 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 508 KiB

After

Width:  |  Height:  |  Size: 673 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 508 KiB

After

Width:  |  Height:  |  Size: 673 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 669 KiB

After

Width:  |  Height:  |  Size: 758 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 669 KiB

After

Width:  |  Height:  |  Size: 758 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 602 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 602 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 602 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 513 KiB

After

Width:  |  Height:  |  Size: 602 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 843 KiB

After

Width:  |  Height:  |  Size: 932 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 842 KiB

After

Width:  |  Height:  |  Size: 931 KiB